LoadManager 的问题
我正在努力弄清楚为什么此代码使用 Honeycomb SDK 可以工作,但在使用兼容性库时却失败。具体来说,getLoaderManager().initLoader(0, null, this)
可与 Honeycomb SDK 配合使用,但在使用兼容性库时,参数似乎有所不同,我不知道该怎么做。
public class SearchActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
/*
*
* The following works fine when using:
* import android.app.LoaderManager;
* import android.content.CursorLoader;
* import android.content.Loader;
*
* but fails when using (requires different parameters)
* import android.support.v4.app.LoaderManager;
* import android.support.v4.content.CursorLoader;
* import android.support.v4.content.Loader;
*
*/
getLoaderManager().initLoader(0, null, this);
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
}
}
I am struggling to figure out why this codes work using the Honeycomb SDK but fails when using the compatibility library. Specifically, getLoaderManager().initLoader(0, null, this)
, works with the Honeycomb SDK but when using the Compatibility library the parameters appear to be different and I am not sure what to do.
public class SearchActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
/*
*
* The following works fine when using:
* import android.app.LoaderManager;
* import android.content.CursorLoader;
* import android.content.Loader;
*
* but fails when using (requires different parameters)
* import android.support.v4.app.LoaderManager;
* import android.support.v4.content.CursorLoader;
* import android.support.v4.content.Loader;
*
*/
getLoaderManager().initLoader(0, null, this);
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我弄错了,它仍然是
getLoaderManager()
而不是getSupportLoaderManager()
。这些参数与 Honeycomb 相同,看起来您的代码中已经正确设置了它。 Eclipse 是否抱怨它采用不同的参数?
Sorry I was mistaken, it's still
getLoaderManager()
notgetSupportLoaderManager()
.The arguments are the same as Honeycomb and it looks like you have it right in your code. Is Eclipse complaining about it taking different params?