Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleCursorAdapter and CursorAdapter

I want to know what are the differences between CursorAdapter and SimpleCursorAdapter. Based on what criteria someone would choose the one or the other. Your experiences working with them? Thank you

like image 995
Antonis Avatar asked Dec 05 '11 08:12

Antonis


2 Answers

I think that the main question is still not answered. SimpleCursorAdapter exists for those who want to save some time making their own CursorAdapter. SimpleCursorAdapter is already made from google and you just tell him how should the layout look like and what ids of widgets you want to fill with your chunks of data, so you dont have to override methods of CursorAdapter and implement them. But you can use only TextView and ImageView in your layout, because it doesn't support more widgets so far.

So as result SimpleCursorAdapter takes like 2 lines of code but extending CursorAdapter means lots more but you have more options for customization. I believe SimpleCursorAdapter should be enough in most cases.

like image 102
Srneczek Avatar answered Nov 01 '22 02:11

Srneczek


CursorAdapter is abstract and is to be extended. On the other hand, SimpleCursorAdapter is not abstract.

Notice that newView(Context context, Cursor cursor, ViewGroup parent) is abstract in CursorAdapter but implemented in SimpleCursorAdapter. This is because SimpleCursorAdapter has a specific mechanism to initiate views while CursorAdapter leaves it up to the developer.

like image 8
Gallal Avatar answered Nov 01 '22 02:11

Gallal