0
我正在創建一個android應用程序,其中m在表格佈局中顯示數據庫中的行。 在這些行中,我顯示了數據庫中的行ID和兩列。 我在行上放置了一個點擊事件。 我想要的是現在得到用戶點擊的特定行的id值,然後根據該行ID顯示數據庫中的所有詳細信息...我知道從數據庫通過select語句顯示的部分。 m無法捕獲onclick事件中的行ID ... 我該怎麼做?任何人有任何想法,請幫助! 這裏是行在顯示細節代碼...在用戶單擊行後從表格佈局中獲取列的一個值
Cursor cursor=database.rawQuery("select * from "+AllValuesTable+" ", null);
Integer index0=cursor.getColumnIndex("ROWID");
Integer index1 = cursor.getColumnIndex("appln_no");
Integer index2 = cursor.getColumnIndex("app_fname");
if(cursor.getCount()>0)
{
cursor.moveToFirst();
do
{
row=new TableRow(this);
row.setId(100);
row.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
//setting the first column
firstCol=new TextView(this);
firstCol.setText(cursor.getString(index0));
rowid=cursor.getInt(index0);
firstCol.setTextSize(16);
firstCol.setTextColor(Color.BLACK);
firstCol.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
row.addView(firstCol); //adding coloumn to row
// Setting up the second coloumn parameters
secondCol=new TextView(this);
secondCol.setText(cursor.getString(index1));
secondCol.setTextColor(Color.BLACK);
secondCol.setTextSize(16);
secondCol.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
row.addView(secondCol); //adding coloumn to row
// Setting up the third coloumn parameters
thirdCol=new TextView(this);
thirdCol.setText(cursor.getString(index2));
thirdCol.setTextColor(Color.BLACK);
thirdCol.setTextSize(16);
thirdCol.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
row.addView(thirdCol);