i have implemented view pager in my code and i have put on-click listener on view pager but my on-click listener does not working i'll post my code
viewpager.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Log.i("***","***");
Toast.makeText(getActivity(), "XXXX", Toast.LENGTH_SHORT).show();
}
});
Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows. ViewPager is most often used in conjunction with android.
just use Relative layout as parent layout and align the button at the bottom... like floating action button.. (layout_alignParentBottom = true) xml if you want that button to be visible in all pages of pager..
OnClickListener, you can defined your click of each button in method public void onClick(View v) . Keyword this refer to the method onclick. It is good to use this way when there are a lot of button in your class file.
Use clicklistener inside the item of ViewPager. This is not working because Child of ViewPager is intercepting event of parent(i.e ViewPager). E.G if you are adding ImageView inside ViewPager using PagerAdapter then use click of ImageView to make it simple
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With