Skip to content

Instantly share code, notes, and snippets.

@mttkay
Created June 26, 2012 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mttkay/2995057 to your computer and use it in GitHub Desktop.
Save mttkay/2995057 to your computer and use it in GitHub Desktop.
Android obtainStyledAttributes
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