Java.lang.IllegalStateException: два разных ViewHolder имеют один и тот же стабильный идентификатор. Стабильные идентифиAndroid

Форум для тех, кто программирует под Android
Гость
Java.lang.IllegalStateException: два разных ViewHolder имеют один и тот же стабильный идентификатор. Стабильные идентифи

Сообщение Гость »


I am working on music app which has songs queue contains duplicate songs (as per user's requirement to repeat the song) with different state , one of them could be in playing state or others not(screenshot).

I have set

Код: Выделить всё

setHasStableIds(true)
to the adapter and implemented

Код: Выделить всё

getItemId
as below:

Код: Выделить всё

 override fun getItemId(position: Int): Long {     return dataset[position].songId.hashCode().toLong() } 
Also I have tried extending as below , I don't think it's good idea ?

Код: Выделить всё

data class QueueSong(private val song: Song) : Song(song) {    val queueId: Int = hashCode() } 
Anyone please help with this, thank you !!


Источник: https://stackoverflow.com/questions/781 ... ame-stable

Вернуться в «Android»