adapter - When should I use BaseAdapter in Android? -


i working on android app in using adapters populate data in listview. confused should use baseadapter. read many questions written should use arrayadapter arrays , arraylist ok , cursoradapter in case of cursor.

i know baseadapter super class of arrayadapter , cursoradapter. have checked question what difference between arrayadapter , baseadapter , listadapter don't explain when should use baseadapter.

when should use baseadapter ?

you should use it:

  • if model data not in data structure there concrete listadapter class, and

  • if determine creating custom adapter better user, or perhaps less development work you, reorganizing data structure

for example, suppose use jsonarray parse snippet of json. jsonarray not implement list interface, , therefore cannot use arrayadapter. none of other adapters match. yet, want show jsonarray in adapterview. in case, choices are:

  • roll through data , convert arraylist, can use arrayadapter, or

  • create custom subclass of baseadapter can adapt jsonarray (a jsonarrayadapter)

  • stop using jsonarray , instead use else parsing json, gson, can populate list directly, allowing use arrayadapter


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -