Android Listview row repeating item

前端 未结 2 1823
梦毁少年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: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);
    }
    

提交回复
热议问题