LoaderManager的范围是什么?
使用 Loaders 创建 Android 应用程序时,每个 Activity 和 Fragment 都应该有自己的 LoaderManager 吗?或者应用程序应该只拥有一个 LoaderManager
吗?最后,用于标识特定 LoaderManager 的“唯一 ID”在类外部是否可见?
具体来说,我无法确定应用程序中的哪些类应该实现 LoaderCallback
方法(即每个片段都应该实现这些回调,还是应该让一个片段实现回调并查询结果) ,根据需要将它们发送到其他片段/活动)?
预先感谢任何可以帮助我的人!我在网上找不到太多关于此的信息。
When creating an Android application using Loaders, should every activity and fragment have its own LoaderManager
? Or should there only be one LoaderManager
that the application owns? And lastly, are the "unique IDs" that are used to identify specific LoaderManager
s visible outside of the class?
Specifically, I'm having trouble deciding which classes in my application should implement the LoaderCallback<Cursor>
methods (i.e. should each fragment implement these callbacks, or should I have one fragment implement the callbacks and query the results, sending them to other fragments/activities as necessary)?
Thanks in advance to anyone who can help me out! I couldn't find too much information about this online.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LoaderManger
由活动管理和拥有。您可以在片段或活动中创建实际的加载器,它们将由相同的 LoaderManager 管理。唯一 ID 用于识别同一活动中可能拥有的不同加载程序。例如ID=0-> FooLoader,ID=1 ->酒吧装载机等LoaderManger
's are managed and owned by the activity. You can create the actual loaders in your fragments or the activity, they will be manged by the sameLoaderManager
. Unique ID's are to identify different loaders you might have in the same activitiy. For example ID=0 -> FooLoader, ID=1 -> BarLoader, etc.