Android Navigation Drawer Selector Color -
i trying change highlight color on navigation drawer fragment. have used pre-built project template navigation drawer. have searched site many different solutions far none of them have worked. currently, have:
list_selector.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@color/listbackground" android:state_activated="false"></item> <item android:drawable="@color/orangebackground" android:state_pressed="true"></item> <item android:drawable="@color/orangebackground" android:state_activated="true"></item> </selector>
navigationdrawerfragment.java posting relevant mdrawerlist constructor/decleration.
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { mdrawerlistview = (listview) inflater.inflate( r.layout.fragment_navigation_drawer, container, false); mdrawerlistview.setselector(r.drawable.list_selector); mdrawerlistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { selectitem(position); view.setselected(true); } }); mdrawerlistview.setadapter(new arrayadapter<string>( getactionbar().getthemedcontext(), android.r.layout.simple_list_item_activated_1, android.r.id.text1, new string[]{ getstring(r.string.title_section1), getstring(r.string.title_section2), getstring(r.string.title_section3), getstring(r.string.title_section4), getstring(r.string.title_section5), getstring(r.string.title_section6) })); mdrawerlistview.setitemchecked(mcurrentselectedposition, true); return mdrawerlistview; }
you should change item position,like this:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@color/orangebackground" android:state_pressed="true"></item> <item android:drawable="@color/orangebackground" android:state_activated="true"></item> <item android:drawable="@color/listbackground"></item> </selector>
Comments
Post a Comment