Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CursorAdapter vs ArrayAdapter for a ListView

I want to fill my ListView with data that's going to come from the web in the form of JSON. The list should be theoretically infinite, with the app making requests for more data if scrolled to the bottom.

  • Should I use a Cursor or an Array(List) adapter to link my online database with my ListView?
  • More generally, what are the arguments to consider when choosing between cursor and array?
like image 639
Jonathan Allard Avatar asked Dec 19 '11 03:12

Jonathan Allard


People also ask

What is the difference between BaseAdapter and ArrayAdapter?

Here is the difference: BaseAdapter is a very generic adapter that allows you to do pretty much whatever you want. However, you have to do a bit more coding yourself to get it working. ArrayAdapter is a more complete implementation that works well for data in arrays or ArrayList s.

What does an Adaptor do for a view like a ListView?

What does an Adaptor do for a view like a ListView? An adapter actually bridges between UI components and the data source that fill data into UI Component.

What is the use of ArrayAdapter in Android?

In Android development, any time we want to show a vertical list of scrollable items we will use a ListView which has data populated using an Adapter . The simplest adapter to use is called an ArrayAdapter because the adapter converts an ArrayList of objects into View items loaded into the ListView container.

What is the role of the SimpleCursorAdapter?

SimpleCursorAdapter . Used to write apps that run on platforms prior to Android 3.0.


1 Answers

Well I think you should look at ContentProviders. They are more natural to the problem that you are trying to solve. You have to implement your custom Cursor which ContentProvider returns on a query request.

Ref:

http://developer.android.com/guide/topics/providers/content-providers.html

like image 52
havexz Avatar answered Sep 29 '22 15:09

havexz