Choose between ArrayAdapter and SimpleAdapter
Asked Answered
P

2

21

I was wondering, is there any guideline, on how we choose between ArrayAdapter and SimpleAdapter.

For every list item, they will be presented by several TextViews and Views, which is being layout nicely. I realize I can implement both without any problem, by either using ArrayAdapter or SimpleAdapter.

Is there any guideline, on how we choose among them? My guess is

  1. ArrayAdapter enables us to add in new item dynamically, even after the list is being shown during that time. Note that, ArrayAdapter is having method add.
  2. SimpleAdapter is used for case, once the list is being shown, there are no more new item can be added.

Is this the guideline we should follow?

Phasia answered 18/6, 2011 at 10:4 Comment(1)
I think you are right. The difference between the two is whether you are adding new elements dynamically (ArrayAdapter) or not (SimpleAdapter). At least, this is what I understand from the official documentation.Gregorygregrory
W
30

Personally, I don't find SimpleAdapter terribly useful. Your model data is rarely naturally in "an ArrayList of Maps", and it is wasteful to be copying stuff around just to get it in an adapter.

I would either use ArrayAdapter (if my model data is an array of objects) or BaseAdapter (if my model data is some other in-memory data structure).

Welldressed answered 18/6, 2011 at 12:12 Comment(0)
P
-1

Array Adapter could be used to fill out a list view from a dynamic array while the simple adapter is used to fill the list view from a Hash Map or Associative array because there is no constructor in the Array adapter that could take An array of keys and an array of int which is the layout ids we want to fill the data in.

Paymar answered 6/5, 2017 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.