开发者

Highlight selected item in ListView

开发者 https://www.devze.com 2023-03-20 23:56 出处:网络
I am using fragments to display a panel wit开发者_如何学运维h two choices, A and B.When the user clicks on a choice, I would like to highlight the individual choice.

I am using fragments to display a panel wit开发者_如何学运维h two choices, A and B. When the user clicks on a choice, I would like to highlight the individual choice.

In onActivityCreated:

setListAdapter(new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_activated_1, settingsNames));

By using the .simple_list_item_activated_1, I get exactly what I want. But how to I override the 'blue' highlight color? It sounds simple enough, but I'm having a lot of trouble.

I've tried it in a roundabout way, but it doesn't select the first item, when the activity is first created. I've tried to make it a 'button' and set drawable when pressed, but didn't work. So, is there a simple way to override the default android styles?

Thank you so much.

0

精彩评论

暂无评论...
验证码 换一张
取 消