Loader类的返回结果类型由声明的泛型类型决定。
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
// Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.)
mAdapter.swapCursor(data);
}
在 onLoadFinished(...) 中得到异步查询的结果。但是结果是Cursor类型。
请问我要怎么同时使用多个不同结果类型的Loader?
例如我自定义了网络查询的 AsyncTaskLoader, 返回的是服务器接口返回的JSON数据
public class NetworkLoader extends AsyncTaskLoader<String>{...}
于是在同一个Activity,我怎么同时使用 CursorLoader 查询联系人信息,又使用 NetworkLoader 向服务器查询信息?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
需要几个 Loader 就通过
LoaderManager初始化几个:然后实现相应的 Callbacks就可以啦:
你可以去github下一个四次元(原微次元) weiciyuan看看