本文介绍了从活动通话片段事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我得到了我的片段,该事件传递给活动,所以我怎么让它如此轮流活动,通知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();

希望帮助!

这篇关于从活动通话片段事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:06