xamarin - How to change a textview in NavigationView app:headerLayout? -


<android.support.design.widget.navigationview         android:layout_width="wrap_content"         android:layout_height="match_parent"         android:layout_gravity="start"         android:id="@+id/nav_view"         app:headerlayout="@layout/drawer_header"         app:menu="@menu/navmenu" /> drawer_header  <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="120dp"     android:background="#ffffff">     <linearlayout         android:layout_width="match_parent"         android:layout_height="60dp"         android:orientation="horizontal"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true">         <ffimageloading.views.imageviewasync             android:id="@+id/imgthunbailuser"             android:layout_width="80dp"             android:layout_height="80dp" />         <textview             android:id="@+id/txtusername"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="16dp"             android:textcolor="#ffffff"             android:text="music store"             android:textsize="18dp" />         <textview             android:id="@+id/txtlast_modified"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:textcolor="#ffffff"             android:layout_marginleft="16dp"             android:layout_margintop="5dp"             android:text="soundcloud"             android:textsize="14dp"             android:textstyle="normal" />     </linearlayout> </relativelayout> 

mainactivity

txtusername = findviewbyid<textview> (resource.id.txtusername); textusername.text="bcdf"; 

i have tried got error @ textusername. i'm making login. need load image, textview drawer_header.how change textview in navigationview app:headerlayout?

you must first reference headerview navigation view. can use reference textview within headerview, this:

var navigationview = findviewbyid<navigationview>(resource.id.nav_view); var headerview = navigationview.getheaderview(0) var txtusername = x.findviewbyid<textview>(resource.id.txtusername); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -