Created
July 2, 2019 17:34
-
-
Save JeffMcKnight/b032ae33f4d4f99360e698e32a6959d0 to your computer and use it in GitHub Desktop.
Static method to return the Tag attribute of an Android View, or, if that is missing, return the name of the ID attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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