I am new to mobile development. I am working on android using xamarin in visual studio 2015. I am following this sample code. I am deploying my app on my device and it's running good. I have basically following functions
- Insert
- Display
- Update
- Delete
All of the functions are running good but on update when i click the update button in update layout first it gets all the data from DB(SQLITE) and then it displays it in Edit Text Boxes In sample code you can see the updateEmployee.cs code. So while updating i m getting the bellow error
I am getting null value in dName while there is a name in name field
Above i have declared the dName dEmail etc like bellow
TextView dName, dEmail, dPhone, dDesignation;
String name, email, phone, designation;
Also in initialize method i am also getting null values and eName etc in initialize is the id in complete_data layout whose axml is as follows
<?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>
Update 1:
Bellow is the code in which i am getting this exception
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 name field is in string and i am assigning this string to my edit text dName and etc as shown in code above. At dName.text = name i am getting this null exception, while the name field contain the name. Is there any other way to do it?
I am not sure what am i missing. Any help would be highly appreciated
