My trouble is: when i get new data, my viewpager that use my custom adapter do not update view. I discovered that many programmer got same bug, so i tried a lot of suggestion but no way works for me. So tired. One more time, read my source and help me understand why i fail with updating view pleaseee!
Here is my FragmentAdapter:
private class SwipeyTabsPagerAdapter extends FragmentPagerAdapter implements
SwipeyTabsAdapter {
private final Context mContext;
private String[] datas;
public SwipeyTabsPagerAdapter(Context context, FragmentManager fm, String[] ds) {
super(fm);
this.mContext = context;
datas=ds;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public Fragment getItem(int position) {
Log.e("new item:", datas[position]);
return SwipeyTabFragment.newInstance(datas[position]);
}
@Override
public int getCount() {
return datas.length;
}
public TextView getTab(final int position, SwipeyTabs root) {
TextView view = (TextView) LayoutInflater.from(mContext).inflate(
R.layout.swipey_tab_indicator, root, false);
view.setText(datas[position]);
view.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mViewPager.setCurrentItem(position);
}
});
return view;
}
}
and here is where i set adapter:
SwipeyTabsPagerAdapter adapter = new SwipeyTabsPagerAdapter(getApplicationContext(), getSupportFragmentManager(),dicts);
mViewPager.setAdapter(adapter);
mTabs.setAdapter(adapter);
mViewPager.getAdapter().notifyDataSetChanged();
By logcat, can see clearly that: only first time, newItem be processed, so view can not be update.