Reputation: 56199
Is possible in Android to findView by String Id?
I add some rows in table programmatically and in next iteration need to remove some of them and I have List id ( "tblRow_1", "tblRow_3" ..}). Can I retrieve by ids from the list?
Upvotes: 5
Views: 4783
Reputation: 62392
Use getResources().getIdentifier()
to retrieve the actual integer resource ID.
example
int resID = getResources().getIdentifier(stringVar, "id", "com.sample.project");
view = findViewById(resID);
Upvotes: 17