[英]How To Assign Instance ID When Initializing LoaderManager
In order to use AsynTaskLoader, I first need to initialize LoaderManger. 为了使用AsynTaskLoader,我首先需要初始化LoaderManger。 The first argument is a unique ID (integer) of the instance.
第一个参数是实例的唯一ID(整数)。
Below is an example code with ID set to 0. 以下是ID设置为0的示例代码。
getLoaderManager().initLoader(0, null, this);
Firstly to use AsyncTaskLoader you need to initialize corresponding Loader and not LoaderManager. 首先,要使用AsyncTaskLoader,您需要初始化相应的Loader,而不是LoaderManager。
You should declare ID as constants like - 您应该将ID声明为常量,例如-
private static final int TASK_A = 1;
private static final int TASK_B = 2;
No, even if you call initLoader again being called before it just skips the onCreateLoader method and directly calls onLoadFinished with cached copy of previous data 不,即使您再次调用initLoader之前,它只是跳过onCreateLoader方法并直接使用先前数据的缓存副本调用onLoadFinished
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.