I m new in android i am trying to create a nested list. From fist list the code below list should be genreate. but it showing error every time on clicking on the first list item and that is in the code below. , this is my code: private ArrayList results = new ArrayList();
Cursor cursor2 = myDb.getAllRows2(myname);
//Cursor cursor2 = myDb.getAllRows();
try {
Log.d("cursor2", "ok");
if (cursor2.moveToFirst()) {
do {
Log.d("cursor2-1", "ok");
// Process the data:
String name = cursor2.getString(1);
String date = cursor2.getString(2);
String number = cursor2.getString(3);
String quantity = cursor2.getString(4);
String milk_type = cursor2.getString(5);
String time = cursor2.getString(6);
// Append data to the message:
results.add(date + " " + time +"\n"+"Quantity:"+quantity+"--->Type:"+milk_type);
Log.d(" name=" + name+"\n"
+" Date=" + date+"\n"
+" Number=" + number+"\n"
+" Qunatity="+ quantity+"\n"
+" Milk Type="+ milk_type+"\n"
+" Time="+ time
+"\n","");
Log.d("cursor2---record", "ok");
} while(cursor2.moveToNext());
}
Log.d("cursor2-close", "ok");
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_2, results));
getListView().setTextFilterEnabled(true);
and xml is:
<?xml version="1.0" encoding="UTF-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
Please help me??
0 comments:
Post a Comment