c# - Xamarin how to assign a string to edit text ? -


i new mobile development. working on android in xamarin using visual studio 2015. getting null reference exception when assigning string edit text. bellow code

void list_itemclick(object sender, adapterview.itemclickeventargs e)     {         click_employee = e.position + 1;         icursor c = dbhelper.getsingleentry(click_employee);         c.movetofirst();         name = c.getstring(c.getcolumnindex(dbhelper.employee_name));         email = c.getstring(c.getcolumnindex(dbhelper.employee_email));         phone = c.getstring(c.getcolumnindex(dbhelper.employee_phone));         designation =     c.getstring(c.getcolumnindex(dbhelper.employee_designation));         dname.text = name;         demail.text = email;         dphone.text = phone;         ddesignation.text = designation;     } 

the exception getting @ point dname.text = name. better understanding please see bellow code

listview list;      edittext dname, demail, dphone, ddesignation;     string name, email, phone, designation;     sqlitehelper dbhelper;     int click_employee;     button upbtn;   private void initialize()     {         list = (listview)findviewbyid(resource.id.listview1);         dname = (edittext)findviewbyid(resource.id.ename);         demail = (edittext)findviewbyid(resource.id.eemail);         dphone = (edittext)findviewbyid(resource.id.ephone);         ddesignation = (edittext)findviewbyid(resource.id.edesignation);         upbtn = (button)findviewbyid(resource.id.updateemploy);     } 

bellow axml data coming in update layout when record selected

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp"> <scrollview     android:layout_width="fill_parent"     android:layout_height="fill_parent">     <linearlayout         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="vertical">         <listview             android:id="@+id/listview1"             android:layout_width="match_parent"             android:layout_height="350dp"             android:divider="#000"             android:dividerheight="1dp" />         <textview             android:id="@+id/ename"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="name" />         <textview             android:id="@+id/eemail"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="email" />         <textview             android:id="@+id/ephone"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="phone" />         <textview             android:id="@+id/edesignation"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="designation" />     </linearlayout></scrollview></linearlayout> 

for more understanding please see link using , following sample code

also have done recommends in this link result same

any appreciated

you've set items textviews in layout you're casting them edittexts in class.

<edittext         android:id="@+id/ename"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="phone" /> 

you should typing rather casting shown below.

dname = findviewbyid<edittext>(resource.id.ename); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -