Question

I have a list populated by a list adapter with data from the server. Regardless of the data returned (or lack thereof) I want the first item of the list to always be the same (an item I created).

How do I call the setData method so that the first item is always there?

Était-ce utile?

La solution

You could copy the dynamic data to a local List and insert the static item at the beginning of the List each time, and then use that List, containing both static and dynamic data, with an ArrayAdapter.

Hope this helped.

Autres conseils

You should use this method:

ListView lv = (initialize your list view here)

lv.addHeaderView(View v); v is a parameter, inflate the item you always want there and put it in this way. It will always show up at the top of the list.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top