Thank you. But in my custom button, how can I get the attribute
defined in android?
For example, if MyButton inherits from Button, how can I get
'TextAppearance_textColor in my
MyButton class?
This is how the android's Button class get the TextAppearance_textColor
case com.android.internal.R.styleable.TextAppearance_textColor:
textColor = appearance.getColorStateList(attr);
break;
But I can't do the same in MyButton since the
'com.android.internal.R.styleable.TextAppearance_textColor' is not
accessible.
So can you please tell me how can I get the textColor in MyButton?
Thank you.
On Tue, Feb 10, 2009 at 10:05 AM, skink <[email protected]> wrote:
>
>
>
> On 10 Lut, 16:34, ying lcs <[email protected]> wrote:
>> Hi,
>>
>> I am writing a custom button.
>>
>> In the android button, I can customize my button like this:
>> <Button android:id="@+id/subtract_button"
>> android:text="-"
>> />
>>
>> And in the Button.java source code, it gets the value like that:
>> In TextView.java:
>> case com.android.internal.R.styleable.TextView_text:
>> text = a.getText(attr);
>> break;
>>
>> My question is if I need to add a new value in the customization for my
>> button.
>> <MyButton android:id="@+id/subtract_button"
>> android:text="-"
>> android:myattribute="myvalue"
>> />
>>
>> How can I get 'myattribute' in my class for my custom button?
>>
>> Thank you.
>
> you should create your styleable attribute by defining declare-
> styleable in attrs.xml (see android's attrs.xml for more info)
>
>
>
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---