这是一个动态生成的表,单击“接受”按钮时,只需将相应行的“状态”字段文本“待定”更新为“已接受”。应该是什么代码?我的查询udpate所有行状态字段从挂起到接受。
Adminactivity.java(dynamically generated column code)
for (int j = 0; j < 1; j++)
{
TextView tv1 = new TextView(AdminActivity.this);
tv1.setText("Acccept");
tv1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT));
tv1.setGravity(Gravity.CENTER);
tv1.setTextSize(12);
tv1.setPadding(5, 0, 0, 0);
// tv1.setTextColor(Color.BLACK);
tv1.isClickable();
tv1.setTextColor(Color.RED);
tv1.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
row1.addView(tv1);
tv1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Integer iid=dbHelper.getid();
dbHelper.accept("accept", "pending",k);
Toast.makeText(getApplicationContext(), "Accepted", Toast.LENGTH_SHORT).show();
// notify();
}
});
}
DBhelper.java public Cursor accept(String accept,String pending) {
SQLiteDatabase db=this.getReadableDatabase();
ContentValues contentValues = new ContentValues();
String query="UPDATE register6 SET status='"+accept+"' WHERE status='"+pending+"'";
Cursor cursor=db.rawQuery(query, null);
if(cursor!=null) {
cursor.moveToNext();
}
return cursor;
}
答案 0 :(得分:0)