Please check this edited code.. its working but not showing the data of database..check box is getting tick but other 2 columns r printing as id and date..Not getting whats wrong in my setviewvalue method..
protected override void OnCreate (Bundle SaveInstace)
{
base.OnCreate (SaveInstace);
SetContentView (Resource.Layout.ListView_layout);
ActionBar.SetDisplayHomeAsUpEnabled (true);
//Gets ListView object instance
Database sqldb1 = ((GlobalClass)this.Application).sqldb;
listItems = FindViewById<ListView> (Resource.Id.listItems);
GetCursorView ();
}
void GetCursorView()
{
Database sqldb1 = ((GlobalClass)this.Application).sqldb;
Android.Database.ICursor sqldb_cursor = sqldb1.GetRecordCursor();
if (sqldb_cursor != null)
{
sqldb_cursor.MoveToFirst ();
string[] from = new string[] {"_id","date","Value"};
int[] to = new int[] {
Resource.Id.ListRow1,
Resource.Id.ListRow2,
Resource.Id.ListRow3
};
//Creates a SimplecursorAdapter for ListView object
SimpleCursorAdapter sqldb_adapter = new SimpleCursorAdapter (this, Resource.Layout.record_view, sqldb_cursor, from, to);
sqldb_adapter.ViewBinder = new MyCustomView();
listItems.Adapter = sqldb_adapter;
}
else
{
}
}
public class MyCustomView:Java.Lang.Object, SimpleCursorAdapter.IViewBinder
{
public bool SetViewValue (View view, Android.Database.ICursor cursor, int i)
{
if (view.Id == Resource.Id.ListRow3)
{
// If the column is IS_STAR then we use custom view.
int is_val = cursor.GetInt (i);
CheckBox cb = (CheckBox) view;
if (is_val != 0)
{
// set the visibility of the view to GONE
cb.Checked = true;
return true;
}
else
{
return true;
}
// For others, we simply return false so that the default binding
// happens.
}
return true;
}
}