Xin chào Tôi đã giải quyết nó cho android OS phiên bản 11 trở lên bằng cách áp dụng phong cách:
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>
activated_background trong thư mục drawable:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/uva_color" />
<item android:state_selected="true" android:drawable="@color/uva_color" />
<item android:state_pressed="true" android:drawable="@color/uva_color" />
<item android:drawable="@color/default_color" />
</selector>
giá trị màu trong thư mục các giá trị:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="uva_color">#c31756</color>
<color name="default_color">#111</color>
</resources>
Và đặt choicemode trong chế độ xem danh sách:
android:choiceMode="singleChoice"
Và cuối cùng, gửi getBaseContext()
đến arrayApdater/customAdapter của bạn làm thông số thay vì getApplicationContext()
.
mMenuAdapter = new MenuListAdapter(this.getBaseContext(), title, icon);
Cũng this link sẽ giúp bạn.
Nhận xét bên dưới nếu bạn gặp sự cố ở bất kỳ đâu. Tôi sẵn sàng trả lời bất cứ lúc nào, tôi không muốn để bất cứ ai gặp rắc rối với điều này như tôi. Chúc mừng!
Nguồn
2013-07-13 07:28:47
Xin chào, tôi không thể làm nổi bật khi một mục trong danh sách xem được nhấp. Tôi có nghĩa là màu sắc nên ở lại cho mục được nhấp khi ngăn mở hoặc đóng – user1340801