I have this problem, I have a FragmentActivity
with a ViewPager
and a ViewPagerAdapter
.
In this ViewPager I have 3 Fragments
that each of them contains a TableLayout
that gets populated programmaticly using a 2dArrayList
.
on a click of a button in the FragmentActivity
layout, I filter the data in the 2dArrayList
and basically need to recreate all 3 Fragments
with the new dataset (run the onCreateView
method in all of them).
So I create an onClickListener
for this button:
private class SlicerSelectedOnClickListener implements OnClickListener {
private ODSharedSlicer slicer;
public SlicerSelectedOnClickListener(ODSharedSlicer slicer) {
super();
this.slicer = slicer;
}
public void onClick(View v) {
String slicerValue = ((Button) v).getText().toString();
Log.d(TAG,"Slicer value: "+ slicerValue +" chosen");
application.currentReport.getODSharedSlicers().get(0).getSharedSlicerSelectedMemebers().add(slicerValue);
ViewGroup parent = (ViewGroup) ((Button) v).getParent();
for (int i = 0; i < parent.getChildCount(); i++)
{
if ((parent.getChildAt(i) != v) && (parent.getChildAt(i) instanceof ToggleButton))
{
((ToggleButton) parent.getChildAt(i)).setChecked(false);
}
}
mPagerAdapter.notifyDataSetChanged();
}
}
As you can see I have a mPagerAdapter.notifyDataSetChanged();
As suggested here:
How to recreate fragment with viewpager intentionally?
at the end of this method, So I expect the adapter to recreate all the Fragment
s, but the onCreateView
from any of the fragments never runs.
Can any one suggest what am I doing wrong.
any assistance would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…