Reputation: 125
I am a beginner at android. I have made a viewpager with two fragments. I have some recycler view item in the first fragment. One recyclerview item will fill a fragment. on swipe to next fragment can I load the details of the recycler view item which i have swiped. or how to pass the position of the recyclerview item to next fragment on swipe please help.
Upvotes: 1
Views: 49
Reputation: 1099
well you can do this solution:
second you should send the data from activity to your second fragment when user swiped the viewpager: you can implement an interface inside your second fragment and call it inside of onPageSelected function :
viewPager.addOnPageChangeListener(new OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {}
public void onPageScrolled(int position, float positionOffset, int
positionOffsetPixels) {}
public void onPageSelected(int position) {
// Check if this is the page you want.
}
});
Upvotes: 1