I\'m new to Android development and I\'m studying to code & design an Android project. I have problem with ViewPager
and can\'t find answer on this site or
viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int Position) {
position=Position;
}
});
You will use any view for clicking without viewpager
and go to details by using the selected position of viewpager
i found something tricky solution for the view pager.As view pager is dont have any click event you can try click events on the child of the view pager.What i mean is to set the on Click listener on each page's root element.That will work surely.
Here is an easy solution.
In your layout XML, in the button tag, set android:onClick="AnyName"
, then on your PagerDemo.java
, place:
public void AnyName(View v) {
// Do your stuff
}
That sets onClickListener
in a ViewPager
.