Created
August 3, 2016 14:08
-
-
Save vincent1086/28c997eda7a2de70fdd34be75f5c4d43 to your computer and use it in GitHub Desktop.
Android - get class inner variable
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
////////////////////////////////////////////////////////// | |
//// @usage getClassField("mPageMargin", ViewPager.class) | |
////////////////////////////////////////////////////////// | |
public int getClassField(String fieldName, Class<?> clz) { | |
try { | |
Field thisField = clz.getDeclaredField(fieldName); | |
return thisField.getInt(thisField); | |
} catch (Exception e) { | |
throw new RuntimeException("Not found field " + fieldName + ", Error : " + e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment