I have an application with tabs. In one tab I need to put data (strings) in rows. To do so I chose tableLayout but when I wanted to use a contextmenu
main.xml:
You need to define an xml which will be used to hold data of each row:
In the above xml i have also included the ImageView, it is not really required but this is just to update you that we can include the other controls also.
& at the last you should have a function in your related class:
private void LoadData()
{
DBAdapter db = new DBAdapter(this);
db.open();
Cursor cur = db.GetData();
private ListView lv = (ListView)findViewById(R.id.myLayout);
lv.setAdapter(null);
if(cur.moveToFirst())
{
String[] from = new String[] {"_id","column1"};
int[] to = new int[] {R.id.col1, R.id.col2};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.grid_item, cur, from, to);
lv.setAdapter(adapter);
}
db.close();
}
}