Oge*_*gen 5 android colors android-listview
我有这个列表视图:
<ListView
android:id="@+id/contactsView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/searchButton"
android:divider="@color/DarkGoldenrod"
android:dividerHeight="0.1dp"
android:listSelector="@drawable/list_selector"
android:choiceMode="singleChoice" />
Run Code Online (Sandbox Code Playgroud)
这是以下代码list_selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:drawable/myRedColor" android:state_pressed="true"/>
<item android:drawable="@android:drawable/myBlueColor" android:state_selected="true"/>
<item android:drawable="@android:drawable/myGreenColor"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
在我的主要活动课中,我提出了以下内容:
contactsView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
arg1.setSelected(true);
selectedContactIndex = (int) arg3;
}
});
Run Code Online (Sandbox Code Playgroud)
contactsView是列表视图,我已经确认它被选中但颜色没有停留.我点击它然后改变然后改变回来.知道为什么吗?
| 归档时间: |
|
| 查看次数: |
3690 次 |
| 最近记录: |