Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Style Name of a specific view - Android

Tags:

android

styles

I have an EditText and a custom Style, and I would like to know how I can programmatically, get the "name" of this style, like below:

<EditText
    android:id="@+id/idValue"
    style="@style/integerNumber"
    ... />

In the code,

EditText edValue = findViewById (R.id.idValue);

In this case, I need to receive "integerNumber". Is there a specific method to get this information? (such as edValue.getResources().getStyle()) ... I could not find at all.

like image 975
user1928221 Avatar asked Oct 27 '25 07:10

user1928221


1 Answers

I'm afraid you can't. Looking at the view constructor (in particular ), the style is used just to define view's properties but it's thrown away afterwards. It is not stored anywhere, so I guess you can't retrieve it from the view object.

If you need to get the style you can still (conventionally) add a tag to the views and behave according to that.

like image 173
fedepaol Avatar answered Oct 29 '25 06:10

fedepaol