Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Static method to return the Tag attribute of an Android View, or, if that is missing, return the name of the ID attribute
public class ViewUtil {
public static String getTagOrIdName(View view) {
if (view != null) {
if (view.getTag() != null) {
return view.getTag().toString();
} else {
return view.getResources().getResourceEntryName(view.getId());
}
} else {
return "null";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.