java - 不推荐使用 getSupportLoadManager()
问题描述
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
int id = (int) viewHolder.itemView.getTag();
String stringId = Integer.toString(id);
Uri uri = TaskContract.TaskEntry.CONTENT_URI;
uri = uri.buildUpon().appendPath(stringId).build();
getContentResolver().delete(uri, null, null);
getSupportLoaderManager().restartLoader(TASK_LOADER_ID, null, MainActivity.this);
}
}).attachToRecyclerView(mRecyclerView);
FloatingActionButton fabButton = findViewById(R.id.fab);
fabButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent addTaskIntent = new Intent(MainActivity.this, AddTaskActivity.class);
startActivity(addTaskIntent);
}
});
getSupportLoaderManager().initLoader(TASK_LOADER_ID, null, this);
}
@Override
protected void onResume() {
super.onResume();
getSupportLoaderManager().restartLoader(TASK_LOADER_ID, null, this);
}
getSupportLoadManager()
已弃用。任何遇到该错误的人我都会真正使用一些帮助。
解决方案
从 Android P (API 28) 开始,Loaders 已被弃用,如Loaders中所写。您应该将 更改getSupportLoaderManager()
为LoaderManager.getInstance(T)
。
LoaderManager是框架的 LoaderManager 的静态库支持版本。
推荐阅读
- java - 如何在 android studio 中使用 POST 请求(java 到 php)创建登录到具有改造的网络服务器?
- r - 在 R 中将函数参数作为向量传递
- mysql - 如何在 Laravel Eloquent 方法或 SQL 中选择具有相同列条件的行
- php - PHP 的垃圾收集器有问题。卡住/冻结。进程什么都不做,只消耗CPU
- android - 为什么我的 recyclerview 没有显示在我的选项卡布局片段上?
- progressive-web-apps - 可以从游戏机/智能电视上的浏览器安装 PWA 吗?
- symfony - 在 Symfony 4 中为每种语言定义一个 ndd
- python - 大写熊猫数据框值的第一个和第三个单词
- python - 我是否必须打开一个 docx 文件才能搜索其中的特定字符串?
- php - 如何在php中获取调用者文件名?