Android Listview row repeating item

前端 未结 2 1824
梦毁少年i
梦毁少年i 2021-01-16 14:19

I have a list where on specific number(position) that i get from shared preferences an imageview should be shown(indicates what song is currently playing) . But i get the po

相关标签:
2条回答
  • 2021-01-16 14:44

    If you are extending BaseAdapter in you Adapter class then this solution will work. https://stackoverflow.com/a/28791031/4531507

    0 讨论(0)
  • 2021-01-16 14:57

    its because of this statement

    if (playpos == position) {
            eq.setVisibility(View.VISIBLE);
        }
    

    the listview recycles views so if you notice the first row and the last row is showing the same. That is because the first row was recycled to the last row

    you can fix this by adding an else onto the if so it would look like

    if (playpos == position) {
            eq.setVisibility(View.VISIBLE);
    }else{
        eq.setVisibility(View.GONE);
    }
    
    0 讨论(0)
提交回复
热议问题