我希望在ListActivity中实现一个Loader,但该活动无法识别getLoaderManager。ListActivity中的getLoaderManager
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dbHelper = new DBHelper(this,DBNAME,FindPackageName(), TABLE_NAME);
sql = dbHelper.getReadableDataBase();
//Log.d("Gaurav","Database Open");
String[] from = new String[]{"word","_id","MyList"};
int[] to = new int[]{R.id.listrow };
simpleCursorLoader = new SimpleCursorLoader(this, TABLE_NAME, from, null, null, null, null, null, null, sql);
//query result will be whole database
//cursor = sql.query(TABLE_NAME, from, null, null, null, null, null);
//startManagingCursor(cursor); //this method is deprecated
//Log.d(TAG,"Cursor Set");
completerOrMyListAdapter = new CompleteOrMyListAdapter(this,
R.layout.completeormylist_adapter, cursor, from, to, dbHelper);
setListAdapter(completerOrMyListAdapter);
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
LoaderManager lm = getLoaderManager();
//if (lm.getLoader(0) != null) {
// lm.initLoader(0, null, this);
//}
//getLoaderManager().initLoader(0, null, this);
}
我想在我的代码的答案,它工作在答复建议的方式,您可能使用以下代替
。 –
[Android开发人员网站](http://developer.android.com/sdk/compatibility-library.html#Using)提供了有关如何使用支持包(以前称为兼容性库)的更多信息以及几种使用其库与它们近似的较新库不同。您还可以查看支持包的API文档链接。 – hotshot309