I've got a following problem:
In Android Studio I generate en EditText
dynamically when an ExerciseButton
is clicked:
public void exerciseButtonClick(View view) {
EditText exercise = new EditText(this);
exercise.setId(exerciseId);
exerciseId++;
}
Later in the code I would like to refer to all my EditText
's via ID. I'm trying something like this but this is not working:
for (int i = 1; i < exerciseId; i++) {
EditText currentEditText = (EditText) findViewById(i);
// further instructions on that EditText
}
The error is of course here: findViewById(i)
, showing Expected resource type to be on of id. How can I solve this problem?