0
我給我的ListView
添加了一些selector
來給它一個定製的外觀。我問在這裏怎麼做My ListView lost its behavior after I changed background color?設置drawable會導致我的應用程序崩潰?
我按照指示步驟。但是,當我將android:background
設置爲我的ListView
指向選擇器時,應用程序崩潰。我不知道爲什麼。當我將它設置回十六進制顏色時,它可以工作。
這裏是選擇XML命名list_item_state.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#808080"/>
<item android:state_focused="true" android:color="#808080"/>
<item android:color="#FFFAF0" />
</selector>
這裏是ListView
XML:
<ListView android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFAF0" <!-- changes are made here -->
android:dividerHeight="1dp"
android:divider="#808080"/>
難道我做錯了什麼嗎?
除了使用這些顏色,一切都很好? –
是的..我已經試圖通過添加這些更改,其工作的示例代碼。 –