【发布时间】:2014-06-28 12:24:01
【问题描述】:
for(int x = 1; x < i ; x++){
// VIEWS
TextView tvx = new TextView(this);
EditText etx = new EditText(this);
EditText editx = new EditText(this);
// ADD VIEW
//set properties
ll1.addView(tvx);
ll1.addView(etx);
ll1.addView(editx);
// sets the ingredient and the amount and cal corresponding
switch(x){
case 1: tvx.setText("Chicken");
etx.setText("200");
editx.setText("100g");
break;
case 2:tvx.setText("eggs");
etx.setText("350");
editx.setText("100g");
break;
case 3:tvx.setText("Bacon");
etx.setText("400");
editx.setText("100g");
break;
case 4:
tvx.setText("Salad");
etx.setText("200");
editx.setText("100g");
}
// // // // // // // //
btn2.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
}
});
大家好,我的代码包含一个 for 循环,以便生成包含 textview 和 2 的行 编辑文本。但是,我不知道在 btn2 onClick 方法中放入什么,因为我在尝试唯一标识每个编辑文本时遇到问题。 例如,如果这些编辑文本中的任何一个要更改,我将无法提取用户的特定输入。
【问题讨论】:
标签: java android android-layout android-edittext android-button