android - set image button background dynamically -


i have defined array of imagebutton dynamically , take buttons background user selected photos, problem when restart app, image buttons not stay, how can make stay "along user selected background it" without define in xml? think of shared preferences not sure if solve problem!

icon[count]= new imagebutton(this); icon[count].setimageresource(r.drawable.p1); icon[count].setimagebitmap(photo); 

to save background color have applied , shared preferences perfect solution.

you need save state of background color , retrieve when restarting app(onrestart()) or onpause() or onresume().

how can make stay "along user selected background it" without define in xml?

using shared preferences

checkout android shared preferences example


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -