3
我已經創建了水平列表視圖,如http://www.dev-smart.com/archives/34中所述。單擊水平列表項中的項目
一切工作正常唯一的問題是,當我們點擊一個元素(單擊單元格的顏色變化)時,我們得到的效果不存在於自定義水平列表中。
有沒有辦法來解決這個問題
我已經創建了水平列表視圖,如http://www.dev-smart.com/archives/34中所述。單擊水平列表項中的項目
一切工作正常唯一的問題是,當我們點擊一個元素(單擊單元格的顏色變化)時,我們得到的效果不存在於自定義水平列表中。
有沒有辦法來解決這個問題
在我的應用我已經添加下列文件到文件夾繪製更改列表項的顏色一旦選擇:
List_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/gradient_bg" />
<item android:state_pressed="true"
android:drawable="@drawable/gradient_bg_hover" />
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/gradient_bg_hover" />
</selector>
gradient_bg.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#f1f1f2"
android:centerColor="#e7e7e8"
android:endColor="#cfcfcf"
android:angle="270" />
</shape>
gradient_bg_hover.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#A6A6A6"
android:centerColor="#757575"
android:endColor="#4A4A4A"
android:angle="270" />
</shape>
希望這有助於:)
你真的需要[編輯],改善這一點。祝你好運。 – Will