0

I've an Activity with a ViewPager, 3 tabs, 3 Fragments, and these fragments are all the same class but with different arguments when created so they are filled with a different list each one.

MainActivity > SectionsPageAdapter

@Override
public Fragment getItem(int position) {
    Fragment fragment = new MyFragment();
    Bundle args = new Bundle();
    args.putInt(MyFragment.TYPE, position);
    fragment.setArguments(args);
    return fragment;
}

The problem is that I need to refresh the Adapter of an individual Fragment onClick, but the adapter is always the last created Fragment Adapter.

How can I solve this without duplicating the fragment class 3 times with different names?

edovino
  • 3,315
  • 2
  • 22
  • 22
Shixons
  • 197
  • 3
  • 13
  • Your approach is not very good. Please have a look at this post http://stackoverflow.com/questions/18088076/update-fragment-from-viewpager?answertab=votes#tab-top – T D Nguyen Nov 04 '14 at 02:16
  • @NguyenDoanTung I want to use notifyDataSetChanged() on the list adapter inside the fragment, not on the ViewPager adapter, also getItemPosition(Object obj) on the ViewPager is never triggered. – Shixons Nov 04 '14 at 03:19
  • Where is this `onClick` method? In the `Activity`? And are you trying to refresh the list within the `Fragment`? – Bryan Aug 15 '16 at 16:53

0 Answers0