I'm going through Big Nerd Ranch's Android Programming book and i'm currently on the chapter that teaches loaders. Also i'm not using android studio and Java, but rather Xamarin/mono for building the apps. In the book it wants me to create a class as such
public abstract class SQLiteCursorLoader extends AsyncTaskLoader<Cursor>
To translate it to C# Xamarin Android it should just be
public abstract class SQLiteCursorLoader : AsyncTaskLoader<ICursor>
However there is not a generified class of AsyncTaskLoader in Xamarin Android. Is this a bug and/or oversight? Or did they create their own class/interface that should be used? I tried IAsyncTaskLoader use the keyboard shortcut in visual studio to try and find the package to import but it didn't find anything.
Remember you are coding in C# and Java generics are...well...Java ;-)
Xamarin.Android
does supply support for some Java generics in the framework (there is aAsyncTask<TParams, TProgress, TResult>
supported among others).You should read the Generic C# classes section under the
Xamarin.Android
limitation guide. Also howXamarin.Android
generates callable wrappers, etc...There is a
CursorLoader
class in the Android framework that is aAsyncTaskLoader<Cursor>
, you could just subclass it:Or you could always code it in Java, build it into a jar/aar and bind it into a .Net library