简体   繁体   中英

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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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