Ich benutze die Android-Support-Bibliothek, um eine Navigationsleiste zu erstellen.Navigationsstatus in Aktionslayout propagieren
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@color/white"
app:headerLayout="@layout/nav_header_landing"
app:menu="@menu/activity_dashboard_drawer"
app:theme="@style/MyActionButtonStyle"/>
ich benutzerdefinierte Menüpunkte erschaffe die actionLayout
<group android:checkableBehavior="single"
android:id="@+id/gp_dashboard">
<item
android:id="@+id/nav_dashboard"
app:actionLayout="@layout/layout_dashboard"
android:icon="@mipmap/ic_dashboard"
android:title=""/>
</group>
Verwendung Dies ist das Layout "layout_dashboard"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:duplicateParentState="true">
<helpers.customViews.RobotoTextView
android:id="@+id/dash_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DASHBOARD"
app:typeface="robotoMedium"
android:textColor="@color/nav_header_state_list"
android:textSize="14sp"/>
<helpers.customViews.RobotoTextView
android:id="@+id/dash_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dash_title"
android:text="@string/dashboard_txt"
app:typeface="robotoRegular"
android:textColor="@color/nav_sub_header_state_list"
android:textSize="12sp"/>
</RelativeLayout>
Jetzt möchte ich die Textfarbe dieses Layout ändern, wenn der Menüpunkt ist ausgewählt. Um dies zu tun bin ich mit der @color/nav_header_state_list
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/greeny_blue" android:state_checked="true"/>
<item android:color="@color/greeny_blue" android:state_pressed="true" />
<item android:color="@color/black"/>
</selector>
Aber der Farbe bleibt gleich, auch wenn der Menüpunkt ausgewählt wird. Die pressed state
funktioniert, aber die checked state
nicht. Bitte helfen Sie mir, das Problem zu lösen.
Das ist mein Problem löst. Vielen Dank – amarok