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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -