Using MergeAdapter; search for a method for determining the data type of a list item in the ListActivity onListItemClicked method

I use the MergeAdapter to create a split list in which each section of the list contains different types of underlying data. Everything works as expected. However, the ListActivity onListItemClicked method seems more complex than when determining the type of data underlying the selected list item. This is because I cannot find a good way to determine the type of object that underlies the selected item unless I save a separate list box map for the type of object. I was hoping I could use the getItemViewType method to return the same type for similar items, but if these items are in separate ListView sections, the MergeAdapter returns a type value that is offset by the location of the section, i.e. the same type of item in another section of the list gets another type value. I feel,that I am missing something obvious ... Any help that any person can provide will be greatly appreciated.

+3
source share
1 answer

I use the MergeAdapter to create a split list in which each section of the list contains different types of underlying data.

As the project page notes MergeAdapter: "If you have questions regarding the use of this code, join and ask them on the cw-android Google Group ."

Luckily for you, I saw your question here.

This is because I cannot find a good way to determine the type of object that underlies the selected item unless I save a separate list box map for the type of object.

getItem() MergeAdapter, , instanceof -, .

+9

Source: https://habr.com/ru/post/1773976/


All Articles