Thursday, 1 January 2015

Get android:key attribute on custom view construcor?



I want to get the android:key attribute on the constructor of my customview. However I've been trying to get it using getAttributeValue and it always return null.


How can this be done?


This is what I'm trying:



public class CustomCheckbox extends CheckBox {

public CustomCheckbox(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

public CustomCheckbox(Context context, AttributeSet attrs) {
super(context, attrs);
String key = attrs.getAttributeValue(null, "key");
Log.v("LOAD", "value: "+key); // This prints value: null
}

No comments:

Post a Comment