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
listadapterclass, andif 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 usearrayadapter, orcreate custom subclass of
baseadaptercan adaptjsonarray(ajsonarrayadapter)stop using
jsonarray, instead use else parsing json, gson, can populatelistdirectly, allowing usearrayadapter
Comments
Post a Comment