Я пытаюсь изменить textColor в моем NavigationDrawer, когда элемент выбран. Я использую RecyclerView в качестве макета для прокрутки. Это основано на учебнике: http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html. это то, что я пытаюсь сделать: Это основной макет:NavigationDrawer RecyclerView изменение выбранного стиля элемента
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="@+id/DrawerLayout"
android:elevation="7sp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.RecyclerView
android:id="@+id/RecyclerView"
android:layout_width="320dp"
android:background="#ffffff"
android:layout_height="match_parent"
android:layout_gravity="right"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
и list_item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rowIcon"
android:paddingStart="16dp"
android:src="@drawable/ic_launcher"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
android:background="?android:attr/selectableItemBackground"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/rowText" />
</LinearLayout>
Как я могу сказать ему, чтобы изменить цвет, когда он выбран?
У меня возник вопрос: вам действительно нужно использовать RecyclerView? учитывая, что у вас есть 10 ems в max? в навигационном ящике? – Droidekas
Да, я поддержал ListView – Haim127