由网友(super model)分享简介:我想提出一个购物清单应用程序,我有两个片段,一个 ProductListFragment 和 ShoppingListFragment 。我有动作条按钮,在 ProductListFragment 。我的问题是,我应该处理的片段或上活动?I am making a shopping list app, and I h...
我想提出一个购物清单应用程序,我有两个片段
,一个 ProductListFragment
和 ShoppingListFragment
。我有动作条
按钮,在 ProductListFragment 。我的问题是,我应该处理的片段或上活动?
I am making a shopping list app, and I have two Fragments
, a ProductListFragment
and a ShoppingListFragment
. I have ActionBar
buttons to add elements to the List
on ProductListFragment
. My question is, should I handle these buttons on the Fragment or on the Activity?
推荐答案
您应该让您的活动来处理您的片段的事件。这可以让你的灵活性,您的设计,让您可以重用片段的其他活动的路线。 这里是如何做到这一点使用事件回调一个很好的例子。祝你好运。
You should allow your Activity to handle the events of your fragments. This allows you flexibility in your design so that you can reuse your fragments in other Activities down the line. Here is a great example of how to accomplish this using event callbacks. Good luck.
相关推荐
最新文章