У меня есть TextView
внутри моего тега NavigationView
. Но я не могу получить его с findViewById
методом:Android: не удалось получить TextView внутри тега NavigationView
<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"
app:itemIconTint="@color/drawer_item"
app:itemTextColor="@color/drawer_item"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/version_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp" />
</RelativeLayout>
</android.support.design.widget.NavigationView>
Я попытался следующие способы, но я всегда получаю null
.
findViewById(R.id.version_name); //null
navigationView.findViewById(R.id.version_name); //null
navigationView.getRootView.findViewById(R.id.version_name); //null
http://stackoverflow.com/questions/33161345/android-support-v23-1-0-update-breaks-navigationview-get-find-header/33163288#33163288 –
Возможные дубликатом HTTP://stackoverflow.com/questions/33199764/android-api-23-change-navigation-view-headerlayout-textview –