简体   繁体   English

我如何使用Loader在Android的小部件中加载数据?

[英]How can i use Loader to load data in a widget in android?

我想使用Loader更新窗口小部件中的数据,但是我发现很难在非活动/片段中使用Loader,并且在参考书或API指南中对此一无所知。有人可以告诉我一些有关吗?

A Loader is designed to be used from within a Fragment or an Activity since it is intended to be used to update some UI component when it finishes it's loading process. 加载程序旨在在Fragment或Activity中使用,因为它打算在完成加载过程时用于更新某些UI组件。

If you need a custom implentation of the Loader, you can extend AsyncTaskLoader ( http://developer.android.com/reference/android/content/AsyncTaskLoader.html ) and use it to process your results. 如果需要自定义加载程序,则可以扩展AsyncTaskLoader( http://developer.android.com/reference/android/content/AsyncTaskLoader.html )并使用它来处理结果。 Another option to initialize the LoaderManager for an activity from another class is to pass the instance of that Activity to the other class and the use this instance. 初始化来自另一个类的活动的LoaderManager的另一种选择是将该Activity的实例传递给另一个类并使用该实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM