How do i access android 'hint' style from my custom component? -
i have created own custom component , use android 'hint' style this:
<com.sheep.emaillistcontainer android:id="@+id/my_component" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="hint use"/>
so question is, how 'hint' style attribute set in constructor of component (to use component)?
- i have looked how it's down in textview example, , see it's trying access android.internal.r.styleable not have access to
thanks in advance lior
you can add method:
public static final string default_namespace = "http://schemas.android.com/apk/res/android"; private string getdefaultnamespaceattributevalue(attributeset attrs, string attribute) { string value = null; int resid = attrs.getattributeresourcevalue(default_namespace, attribute, 0); if (resid != 0) { value = getcontext().getresources().getstring(resid); } else { value = attrs.getattributevalue(default_namespace, attribute); } return value; }
then use this:
public emaillistcontainer(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); string value = getdefaultnamespaceattributevalue(attrs, "hint"); }
Comments
Post a Comment