Created
July 25, 2011 21:30
-
-
Save mttkay/1105281 to your computer and use it in GitHub Desktop.
Workaround for Android issue 9656
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 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works fine. Thanks a lot!