J'ai un TextView
dans mon tag NavigationView
. Mais je ne peux pas l'obtenir avec findViewById
méthode:Android: impossible d'obtenir TextView à l'intérieur de la balise 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>
J'ai essayé suivant façons, mais j'obtenir toujours 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 –
double possible de http://stackoverflow.com/questions/33199764/android-api-23-change-navigation-view-headerlayout-textview –