Call time getItem() in FragmentPagerAdapter
I have a little problem with the PagerAdapter in Android. This is my
situation:
I have ActivityA which holds 1 fragment for phones and 2 fragments for
tablets.
FragmentA contains a ListView
FragmentB contains a ViewPager which contains currently two other
fragments (BA and BB)
When I select an item in FragmentA it send the selected item to FragmentB
where FragmentBA and FragmentBB show the details of the selected item.
On tablets it works fine but on phones not. On phone an ActivityB handles
FragmentB. This activity will be started after I select an item.
This is how I get fragments BA and BB in FragmentB
public void setItem(Item item) {
FragmentBA fba = (FragmentBA) getFragmentManager()
.findFragmentByTag("android:switcher:" + R.id.pager + ":0");
FragmentBB fbb = (FragmentBB) getFragmentManager()
.findFragmentByTag("android:switcher:" + R.id.pager + ":1");
fba.setItem(item);
fbb.setListAdapter(new ListAdapter(
getActivity(), item.getStuff()));
}
On phones both fragments (BA and BB) are null becaus the getItem() method
in the FragmentPagerAdapter has not been called.
So my question is: When the "getItem()" method is invoked? And where i can
call the setItem() method in FragmentB?
Thanks and sorry for bad english
No comments:
Post a Comment