我有一個表視圖,其中我通過xml填充行像這樣 TableLayout table =(TableLayout)findViewById(R.id.tblLayoutPop);Android通過ID獲取元素組,然後通過標記選擇
for(int i=0;i<3;i++){
TableRow row = (TableRow) LayoutInflater.from(Popup.this).inflate(R.layout.row, null);
row.setTag(i);
((TextView)row.findViewById(R.id.header)).setText("Some Text");
EditText ed= (EditText) row.findViewById(R.id.editText);
ed.setTag(i);
Button add= (Button) row.findViewById(R.id.buttonAdd);
add.setTag(i);
Button remove= (Button) row.findViewById(R.id.buttonRemove);
remove.setTag(i);
table.addView(row);
}
和XML是here看起來像
有3點這樣的行,現在添加按鈕的點擊,我想增加它的特別編輯文本
爲此,我想這一點,選擇先編輯文本,然後按標記獲取
public void add(View v){
String tag = v.getTag().toString();
Log.d("TAG", tag);
int position = Integer.parseInt(tag);
View eds= findViewById(R.id.editText);
EditText ed= (EditText) eds.findViewWithTag(position);
ed.setText(tag);
}
這不起作用而且我需要一種方法來選擇相應的編輯文本。如何做到這一點
任何幫助,非常感謝
感謝
老兄這是它:)非常感謝! –