所以,我得到了我的片段,该事件传递给活动,所以我怎么让它如此轮流活动,通知B片段做一些事情。我想B片段来填充自定义列表时,片段A有一个列表项点击。因此,它发送事件的活动,现在我怎么活动在B片段称之为事件?
So, I got the event in my fragment to pass to the activity, so how do I make it so the activity in turns, notifies fragment B to do something. I want to fragment B to populate a custom list when fragment A has a list item clicked on. So, it sends the event to the activity, now how do I get the activity to call events in fragment B?
这样做会是这样在你活动的一种方式:
One way to do it would be like this in your activity:
FragmentB fragmentB = (FragmentB)getFragmentManager().findFragmentById(R.id.fragmentBId);
fragmentB.performSomeTask();
这是当然,假设你有FragmentB公开通俗易懂的方法称为performSomeTask()的;
This is of course assuming that you have a publicly accessibly method in FragmentB called performSomeTask();
希望帮助!