How about? A help please, I have this code in which I add 10 EditText
to my activity
.
for(int i=0; i<10; i++) {
EditText columna = new EditText(this);
columna.setHint("Texto " + i);
columna.setId(i);
mlayout.addView(columna);
}
Then I generate a Button, in which I want to recover the text of the 10 EditText, the code of my button is as follows:
Button btnGuardar = new Button(this);
btnGuardar.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
btnGuardar.setId(0);
btnGuardar.setText("GUARDAR");
mlayout.addView(btnGuardar);
btnGuardar.setOnClickListener(new ButtonsOnClickListener(this,0));
I have a class for the Listener of each of my activity buttons, for this case it would be ...
class ButtonsOnClickListener implements View.OnClickListener {
Context context;
int numButton;
public ButtonsOnClickListener(Context context, int numButton) {
this.context = context;
this.numButton = numButton;
}
@Override
public void onClick(View v) {
switch (numButton) {
case 0:
//Aqui es donde deseo obtener el contenido de mis EditText
break;
}
}
}
Any ideas? Thank you in advance for your attention.