TextView Edit = new TextView(this);
Edit.setClickable(true);
Edit.setPaintFlags(Edit.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);
Edit.setText("Edit");
Edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(ViewTransactions.this,
UpdateTransaction.class);
myIntent.putExtra("Id",acd);
Toast.makeText(ViewTransactions.this, "This is my Toast message!"+ acd,
Toast.LENGTH_LONG).show();
startActivity(myIntent);
finish();
}
});
Edit.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT));
Edit.setPadding(5, 5, 5, 5);
Edit.setBackgroundColor(Color.GRAY);
Ll = new LinearLayout(this);
params = new LinearLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 2, 2, 2);
//Ll.setPadding(10, 5, 5, 5);
Ll.addView(Edit, params);
tr.addView((View) Ll);
我创建了一个TableRow动态但我希望从TableRow中的TextView中单击的TableRow的id。但是,每次单击编辑或删除时,它都会占用表格的最后一行,而不是我选择的行。我所看到的其他论坛,但他们是整行,而不是一个特定的细胞上又名TextView的how my table looks like在表格布局中从TextView获取单击行值Android
使用listview可能会更好。 – DroiDev
我已经做了很多我的表,我没有时间将其更改为列表视图,因为你已经注意到即时更新和删除 –
任何帮助在这里会受到欢迎 –