I want to Toast a message on button click using viewpager also I want more information on how to access views in viewpager.
I have tried following code.... not worki
Leave your code all the same but change:
((ViewPager) collection).addView(view, 0);
return view;
to
((ViewPager) collection).addView(v, 0);
return v;
you did the onclick right on a button that was inflated, then you inflated another view iwth resId and rendered it on the screen, that button exists in the memory of your app but no where else, by returning v, that button is drawn and the onclicklistener is invoked on click.