Find view by name
you have to find views by identifier when dealing with xml, but you can look up the identifier by using getIdentifier(String name, ...) which is useful if you have your layouts numbered for example. Just be aware that such a lookup is relatively expensive.
to complete the answer
int id = getResources().getIdentifier(name, "id", context.getPackageName());
View view = findViewById(id);
Yes, we can find any static resources by name too.
int id = getResources().getIdentifier(name, "id", context.getPackageName());
View view;
if(id != 0) {
view = findViewById(id);
}
getResources().identifier will return 0 always if resource not found or name doesn't match.