简体   繁体   中英

change background image by user in android

I have 2 images bg.jpg and bg2.jpg in drawable-hdpi folder in my app.

I want show list of picture then user select one picture for background image for app.

And who i can get list of file in drawable-hdpi folder

Google--> Android How to change background dinamically --> 10000000 results --> first result--> A friend of stackoverflow:

how to change the xml background in android dynamically?

LinearLayout root=(LinearLayout)findViewById(R.id.root);
if(select 1st picture)
{root.setBackgroundResource(R.drawable.bg_image1);}
else
{root.setBackgroundResource(R.drawable.bg_image2);}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM