I am creating subclasses of various Android widgets to create my own widgets. Here is what I have done so far:
(defined in my res/values/attr.xml)
<attr name="font">
<enum name="ARIAL_BOLD" value="1" />
<enum name="ARIAL_ROUND_MT" value="2" />
<enum name="HELVETICA" value="3" />
<enum name="HELVETICA_BOLD" value="4" />
<enum name="GILSANCE_LIGHT" value="4" />
</attr>
<declare-styleable name="EditText">
<attr name="font" />
</declare-styleable>
<declare-styleable name="Button">
<attr name="font" />
</declare-styleable>
<declare-styleable name="TextView">
<attr name="font" />
</declare-styleable>
Then in my EditText I use this as:
public class EditText extends android.widget.EditText {
public EditText(Context context) {
super(context);
}
public EditText(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.EditText);
}
}
Now I want to read the value of the enum that has been set in the XML code. How can I read it? Then, based on the font supplied, I want to set my custom font. Any help will be appreciated.