Is it possible to drive several Views of the same type into the list?
For example, like this:
private List<EditText> editTexts; editTexts.add((EditText) findViewById(R.id.ask1)); Yes, and this can sometimes be found, especially when the markup contains a large number of elements of the same type. In your case, this is EditText . I met with the ImageView .
To make the answer more complete, a small example:
List<EditText> edList = new ArrayList<>(); int[] edIds = { R.id.ed_1, R.id.ed_2, R.id.ed_3, R.id.ed_4 ... R.id.ed_100 }; for (int i = 0; i < edIds.length; i++) edList.add((EditText) findViewById(edList[i])); This approach has its drawbacks not only in supporting the code, but it can be done that way.
Source: https://ru.stackoverflow.com/questions/551560/
All Articles
editTexts = new ArrayList<EditText>()- Chubatiy