I have an activity , which holds two fragments via view pager. I have an arraylist displayed on fragment A, and a list view of items in fragment B. When I check some of these items and click on a button they are passed to the array list of fragment A and should be displayed first.
The data does pass to fragment A as it is supposed to. The problem is that it doesn't display the refreshed array list.
I tried making the ViewPager member static, and then pass it to fragment A every time I click that button in fragment B to pass the content to fragment A. Then in fragment A I do notifyDataSetChanged() on that adapter member. It still doesn't work though.
public class PagerActivity extends FragmentActivity implements MainFragment.AddToHistoryInterface
{
static ViewPagerAdapter adapter;
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_pager );
ViewPager viewPager = ( ViewPager ) findViewById( R.id.viewPager );
adapter = new ViewPagerAdapter( getSupportFragmentManager() );
viewPager.setAdapter( adapter );
}
public static void removeFromB( List<Password> listFromB )
{
MainFragment.fromBtoA( listFromB, adapter );
}
Then, in fragment A: .... ...
public static void fromHistoryToMain( List<Password> listBackToMain, ViewPagerAdapter adapter )
{
passwordsList.addAll( 0, listBackToMain );
adapter.notifyDataSetChanged();
}