Created
June 26, 2012 10:50
-
-
Save mttkay/2995057 to your computer and use it in GitHub Desktop.
Android obtainStyledAttributes
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 MyWidget(Context context, AttributeSet attrs, int defStyle) { | |
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyWidget, defStyle); | |
// read attribute values | |
boolean userBoolAttr = a.getBoolean(R.styleable.bool_attr, false); | |
int userIntAttr = a.getInteger(R.styleable.int_attr, 0); | |
// do something with these values | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment