I've made my own custom adapter extended from BaseAdapter to show a listview and so on...
I want it to support single and multi selection, so it must have stable ids. I've checked with the ADAPTER.hasStableIds()
and the result is false.
I've overrided this method to do try to get stables ids with no luck.
public long getItemId(int position) {
return (long) getItem(position).hashCode();
}
Any idea how to make it? thanks!
Override hasStableIds to return true.
Also the data on your adapter must either override hashCode()
or has some kind of id field to be returned on getItemId
.
Add this in your adapter:
init {
setHasStableIds(true)
}
override fun getItemId(position: Int): Long = position.toLong()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With