This question is about setting the "style" attribute programmatically,
but it needs a bit of background first.
I wish to create a custom component which will looks like a EditText
box but not actually allow direct input. (When focused or touched it
will pop up a dialog to allow data to be entered).
I have created a class:
class MyEditText extends TextView {
MyEditText(Context c, AttributeSet as) {
super(c, as);
};
...
}
in my xml layout file, which uses this component, I use the custom
component with:
<com.nigeleke.widget.MyEditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5px"
android:layout_marginRight="5px"
style="@android:style/Widget.EditText"
android:hint="@string/hint" />
which achieves the desired effect... however, it means that any
client of this "EditText" component must add the
'style="@android:style/Widget.EditText"' attribute. I would prefer
not to force clients to do this, so I'm looking for ways to
programmatically set the style. Something like adding a line:
class MyEditText extends TextView {
MyEditText(Context c, AttributeSet as) {
super(c, as);
as.setStyleAttribute(Widget.EditText); // <<<<<
};
...
}
Also, I realise doing this programmatically will lead to other
drawbacks - i.e. the client of my component actually wanting to set
their own style).
Any help on this problem, or other approaches (if this isn't the
recognised "android way") would be much appreciated.
Many thanks,
Nigel
--
http://nigel-eke.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---