I have an interaction and inside it I create several EditText
dynamically, but how do I keep the id for each EditText
?
My code :
for (int j = 0; j < vet.length; j++) {
EditText nome = new EditText(this);
nome.setId(0+x);
EditText sobrenome = new EditText(this);
sobrenome.setId(1+x);
x = x+2;
}
I tried this logic, but I realized that its the size of my vector is 3 for example, it creates 3 pairs of EditText
(name + surname), but the 3 pairs have the same id, which makes sense, and I needed to know if I clicked on the 1st, 2nd, or 3rd names.
Even with onClick()
I can not differentiate the "names".
Note: I'm putting all these EditTexts in a LinearLayout
, if it was in a ListView
I could get the position at least.
Do you know any Android method to achieve this? Thank you in advance.