Click here to Skip to main content
16,017,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using view pager to display set of items like horizantal scroll view.So i have used pager adapter for that to load the data.My problem is when i swipe to other items when data is reloaded,it came back to the old position in which it has started.

I want to stay in the item which i am viewing now also the datas must be updated in all items.How can i achieve this?

What I have tried:

Here is my code for view pager and its adapter calling :

mScorePAgerAdapter = new ScorePagerAdapter(mContext,mFixturesList);
mScorePager.setAdapter(mScorePAgerAdapter);
int index = getLiveMatchIndex(mFixturesList);
mScorePager.setCurrentItem(index);
mScorePAgerAdapter.notifyDataSetChanged();
// isLiveMatch = checkMatchState(mFixturesList,index);
mScorePager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

}

@Override
public void onPageSelected(int position) {
setViewPagerIndicator(position,mFixturesList);
}

@Override
public void onPageScrollStateChanged(int state) {

}
});
Posted
Updated 30-Jun-16 23:11pm

1 solution

See Managing the Activity Lifecycle | Android Developers[^]. You need to save and restore state information when some of these events occur.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900