I need to add an icon and some text to a button, in code (not xml), in my Android app.
The icon (a stock icon, “expander_open_holo_light.9.png”) should be on the left and the text on the right.
I can’t find any clue…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look at setCompoundDrawableWithIntrinsicBounds(). You can find the info here:
http://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)
Basically, that is the way to set the android:drawableLeft property of your button programatically.