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.
Domanda
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?
Soluzione
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.
Altri suggerimenti
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.