change text to image and back on button at runtime in Android -


i want change button's text image, , (instead image want text back) on user interactions, @ runtime. how can this? can show me example?

as far understood can't use image button, because can't add text on it. tried use

setcompounddrawables 

but not working me (no visible change on button). here code:

 button button = (button) findviewbyid(r.id.button1);   drawable mydrawable = this.getresources().getdrawable(r.drawable.ic_launcher);  mydrawable.setbounds(0, 0, 0, 0);   button.setcompounddrawables(mydrawable, null, null, null); 

please help

i think problem

mydrawable.setbounds(0, 0, 0, 0); 

since you've given 0 left, top, right, bottom, there no visible change. try give values 10 or 15 right , bottom, , you'll able see change.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -