I am trying to get a basic matrix cursor running, but for some reason the list remains empty. Would appreciate if someone could spot what may be wrong with the code?
String []columns = new String[] {"_id","Title","Desc"} ;
MatrixCursor mc = new MatrixCursor(columns);
startManagingCursor(mc);
for(int i=0; i< 200;i++)
{
mc.addRow(new Object[]{i, "test"+i ,"..."});
}
ListView lv = (ListView)findViewById(R.id.alist);
int [] r = new int[1];
r[0] = R.id.atext; // the id of the textview in test_list_item layout
String [] s= new String[1];
s[0] = mc.getColumnName(1); // the column to be used "Title"
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,android.R.layout.test_list_item,mc,s,r);
lv.setAdapter(adapter);
The reason the layout was not read was due to the incorrect layout being called:
SimpleCursorAdapter(this,android.R.layout.list_item,mc,s,r);
Instead of:
SimpleCursorAdapter(this,R.layout.my_list_item,mc,s,r);