Reputation: 3102
Here is my button on click listener. I am trying to listen to the onclick event firing. But it is not working. I have tried the method given in develop.android.com. But this method seems to be not working. Can anyone point out the mistake that I am doing here?
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle args = getArguments();
v = inflater.inflate(R.layout.product_fragment, container, false);
Button button = (Button) v.findViewById(R.id.buynow_button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getActivity(), "test", 2000);
}
});
return v;
}
Upvotes: 1
Views: 798
Reputation: 763
Toast.makeText(getActivity(), "test", 2000);
Needs to be changed to:
Toast.makeText(getActivity(), "test", Toast.LENGTH_SHORT).show();
Upvotes: 5
Reputation: 2624
You are not calling the show function on Toast.
Toast.makeText(getActivity(), "test", 2000).show();
Upvotes: 9