Highlight selected item in “ListFragment”?

前端 未结 7 774
情歌与酒
情歌与酒 2020-12-16 02:35

I have posted the same problem a couple of times but it hasn\'t yet been resolved. I have a ListFragment and I want to highlight the selected item in the list.

7条回答
  •  抹茶落季
    2020-12-16 03:32

    I wasn't getting what I wanted so I kept on digging and came up with a "cheap" solution which might not be the best practice but does the job. I wanted the item to be highlighted when selected and the color should go away when other item is selected from the listFragment. This is what worked for me- I defined a static View V; and initialized it V = new View(getActivity()); Then inside my

    onListItemClick(ListView l, View v, int position, long id)

                V.setBackgroundResource(0);
                v.setBackgroundResource(R.color.BLUE);
                V = v;
    

提交回复
热议问题