Skip to content

Instantly share code, notes, and snippets.

@mttkay
Created July 25, 2011 21:30
Show Gist options
  • Save mttkay/1105281 to your computer and use it in GitHub Desktop.
Save mttkay/1105281 to your computer and use it in GitHub Desktop.
Workaround for Android issue 9656
public class MyLibrary {
public static final String XMLNS = "http://mylib.com/schema"
}
// in widget class
public class MyWidget {
public MyWidget(Context context, AttributeSet attrs) {
// don't use obtainStyledAttributes, but getAttributeResourceValue:
int myAttr = attrs.getAttributeResourceValue(MyLibrary.XMLNS, "myAttr", -1);
}
}
// in XML:
<LinearLayout xmlns:mylib="http://mylib.com/schema">
<com.mylib.MyWidget mylib:myAttr="1" />
</LinearLayout>
@casidiablo
Copy link

Works fine. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment