Reputation: 13
I created an AsyncTaskLoader:
public class MyAsyncLoader extends AsyncTaskLoader<List<MyObject>> {
private MyDataSource myDb_source;
public MyAsyncLoader(Context context) {
super(context);
myDb_source = new MyDataSource(context);
myDb_source.open();
}
@Override
public List<MyObject> loadInBackground() {
List<MyObject> my_records = myDb_source.getAllRecords();
return myObject_records;
}
@Override
public void deliverResult(List<MyObject> data) {
if(isStarted()){
super.deliverResult(data);
}
}
}
In my Activity class I have something like this:
public class InActivity extends Activity implements LoaderCallbacks>{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_in);
.
.
.
.
@Override
public Loader<List<MyObject>> onCreateLoader(int id, Bundle args) {
MyAsyncLoader myAsyncLoader = new MyAsyncLoader(this);
return myAsyncLoader; // Here i get the ERROR: Type mismatch: cannot convert from MyAsyncLoader to Loader<List<MyObject>>
}
return myAsyncLoader; // Here i get the ERROR: Type mismatch: cannot convert from MyAsyncLoader to Loader>
How can i make this work? Thanks for help.
Upvotes: 0
Views: 318
Reputation: 2139
Check what you imported android.support.v4.content.Loader, not the some other thing.
Upvotes: 1