简体   繁体   中英

Android: How to update Background color of Activity when Thread completes

In the xml i have given background image for my root Layout. In a program I want to replace the image with black color after the background data completes. intention is user will see the progress bass and the background with company logo. but i cannot populate the list on top of the background image as it is not readable. so I want to apply a black color after data populates.

Please help me. thanks in advance.

get instance of root layout inside activity and update background color when thread completed . lets assume its a linear layout :

LinearLayout rootLayout ;

in

onCreate()
{

rootLayout = (LinearLayout)findViewById(R.id.rootLayout); //whatever you given in xml 

}

when thread completes

runOnUIThread(new Runnable( run() { rootLayout.setBackgroudResource(R.color.black) } ));

//please verify typos n syntax

hope you already added black <color black>#000000</color> in res/values

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