1

I am making an app for studies with tabbedActivity plus the button is not taking the action, someone knows to explain the reason, I have tried several forms but all are without action, does not give error and breaks the app but the button nothing

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        rooView = inflater.inflate(R.layout.fragment_teste, container, false);
        final Context context = getContext();
        button = (Button) rooView.findViewById(R.id.button);
        button.setOnClickListener((View.OnClickListener) this);
        return rooView;
    } 

@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                Toast.makeText(getContext(), "Teste", Toast.LENGTH_LONG).show();
                break;
        }
    }

1 Answers1

1
    Button button;
    View rootView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        rooView = inflater.inflate(R.layout.fragment_teste, container, false);
        button = (Button) rooView.findViewById(R.id.btConfirm);
        button.setOnClickListener(this);
        return rooView;
    } 

@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btConfirm:
                Toast.makeText(getActivity(), "Teste", Toast.LENGTH_LONG).show();
                break;
        }
    }
Android Mediocre
  • 310
  • 3
  • 14