I know how to dynamically determine an identifier by calling setID() . In order for the identifier to be unique, I used ids.xml and passed the setID() identifier from the pre-generated identifier pool.
Question 1: Is it possible to assign an identifier without using ids.xml , since I cannot predict how many identifiers I will need at runtime?
I tried to get around the first problem presented in Question 1 by dynamically assigning each of them an identifier based on its label hash (each label is unique), but there is no way to guarantee that this ID will not collide with the identifier automatically generated in R.java .
Question 1.1: How can I resolve the name conflict of names?
Question 2: Suppose I have an ID value that I assign and generate dynamically. Since the above identifier does not appear in R.id , findViewById() will not be used to get the view. Therefore, how can I get a view when the identifier is known?
Answer 2:. You can get a view by its corresponding identifier only after onCreate() returns control (completed).
android android-layout android-widget
Mroth
source share