我在表格行中添加一个动态radiobutton
显示数据的行。db
我想通过单击来编辑行radiobutton
。如何识别radiobutton
点击了哪一行?
String selquery = "select * from student";
Cursor cursor = StudentDB.rawQuery(selquery,null) ;
if(cursor != null){
if ((cursor != null && cursor.getCount()< 1))
{
cursor.close();
}else{
int numberOfRecords = cursor.getCount();
cursor.moveToFirst();
TableLayout table = (TableLayout)dialog.findViewById(R.id.datatablellayout);
for(int i=0;i< numberOfRecords;i++){
// Inflate your row "template" and fill out the fields.
TableRow row = (TableRow)LayoutInflater.from(SampleDbAct.this).inflate(R.layout.tablewithrow, null);
((TextView)row.findViewById(R.id.datatable_name)).setText(cursor.getString((cursor.getColumnIndex("name"))));
((TextView)row.findViewById(R.id.datatable_rno)).setText(cursor.getString((cursor.getColumnIndex("roll_number"))));
((TextView)row.findViewById(R.id.datatable_place)).setText(cursor.getString((cursor.getColumnIndex("place_name"))));
((TextView)row.findViewById(R.id.datatable_class)).setText(cursor.getString((cursor.getColumnIndex("class"))));
((TextView)row.findViewById(R.id.datatable_email)).setText(cursor.getString((cursor.getColumnIndex("e_mail"))));
((RadioButton)row.findViewById(R.id.radio_btn)).setText(cursor.getString((cursor.getColumnIndex("e_mail"))));
table.addView(row);
/*System.out.println("You have entered the Name as:" +cursor.getString((cursor.getColumnIndex("name")))+":");
System.out.println("You have entered the Roll No as:" +cursor.getString((cursor.getColumnIndex("roll_number"))));
System.out.println("You have entered the Class as:" +cursor.getString((cursor.getColumnIndex("class"))));
System.out.println("You have entered the place as:" +cursor.getString((cursor.getColumnIndex("place_name"))));
System.out.println("You have entered the email as:" +cursor.getString((cursor.getColumnIndex("e_mail"))));*/
if(!cursor.isLast())
cursor.moveToNext();
}
table.requestLayout();
cursor.close();
}
}
StudentDB.close();