I am struggling to figure out wh开发者_运维技巧y 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) {
}
}
Sorry I was mistaken, it's still getLoaderManager()
not getSupportLoaderManager()
.
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?
精彩评论