Gustavo J. Moretti
Gustavo J. Moretti

Reputation: 63

Retrieving data from a HashMap in an Adapter (GetView method)

I created a list based on this example:

http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/

In GetView method, need to access information that is stored only in the HashMap. I can access using "adapter.getItem (position). ToString ()" but this way, keys and values ​​come together in a single string, like this:

{date=2011-07-25 19:30:00, id=1, caption=Test Caption, title=Test Title, bookmark=true}

You can retrieve this data separately? For example, only the value of "bookmark" field

Please include an example. I am new to developing for Android.

Upvotes: 0

Views: 2030

Answers (1)

Gal Ben-Haim
Gal Ben-Haim

Reputation: 17803

remember that you know the data type that is used with the adapter.

instead of using toString, just get the item and use it as you usually do.

for example:

HashMap<String, String> i = (HashMap<String, String>) adapter.getItem(position);
i.get(ITEM_TITLE);

Upvotes: 3

Related Questions