1
在我的应用程序中,我想要在ListView
中选择的项目具有不同的背景。事实上,我没有一个简单的ListView,它的ListFragment
其中我通过getListView()
方法得到我的ListView。我编程应用的选择,如:针对所选清单项目的不同背景
ListView listview = getListView();
listview.setSelector(R.drawable.tablet_settings_list_selector);
而且列表选择XML是什么样子,
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:state_focused="false"
android:drawable="@drawable/tablet_menu_panel" />
<item android:state_pressed="true" android:state_focused="true"
android:drawable="@drawable/tablet_menu_panel_ontap" />
<item android:state_activated="true"
android:drawable="@drawable/tablet_selected_menu" />
</selector>
这是我的列表看起来应该像:
,你可以看到,选定的列表项具有不同的背景,向外箭头。那么我怎么能做到这一点?
突出的箭头是在另一个片段? – Luksprog 2012-08-02 07:48:54
http://stackoverflow.com/questions/2562051/listview-item-background-via-custom-selector看这里 – Waqas 2012-08-02 07:55:14
@Luksprog:是的。这就是为什么它有点问题。 – Rajkiran 2012-08-02 09:52:11