the_big_blackbox the_big_blackbox - 1 year ago 124
Java Question

get xml attribute of button android java

Please help I have the a number of buttons with text and images in a layout in my activity_main.xml file.

android:text="pic1" />

Each of the other buttons have a different @drawable resource, id and text.

Question: How would I programmatically loop through each of the buttons in and obtain the value of the @drawableTop attribute, so in the above case - ring

Answer Source

From documentation:

Drawable[] getCompoundDrawables ()

Returns drawables for the left, top, right, and bottom borders.



will return drawable for top.