How can I change the background color for an specific row properly in a ListView? (Android)

前端 未结 7 2016
别那么骄傲
别那么骄傲 2020-12-17 05:05

I have spent some days trying to solve a problem I have with ListViews on Android. I would like to implement a single selection list box using a ListView. So, I would like t

7条回答
  •  心在旅途
    2020-12-17 05:39

    I believe this is due to the way ListViews number and re-use rows. So, rather than using parent.getChildAt(i) to get the row you wish to manipulate, use the View object passed to onItemClick itself.

    view.setBackgroundColor(SELECTED_COLOR);
    

提交回复
热议问题