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()
已弃用。遇到该错误的任何人我真的会需要一些帮助。
最佳答案
从 API 28 开始,加载程序已被弃用:
Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData. ViewModels survive configuration changes like Loaders but with less boilerplate. LiveData provides a lifecycle-aware way of loading data that you can reuse in multiple ViewModels.
更多信息:
关于java - getSupportLoadManager() 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54082085/