开发者

How can I load an image from sdcard and use them to change the background to xml layout files?

开发者 https://www.devze.com 2023-03-01 23:51 出处:网络
As I said in the title really, I have several screens in xml files and I use the them as in this application:

As I said in the title really, I have several screens in xml files and I use the them as in this application:

Android Homescreen

and I need to update several files in t开发者_运维技巧he first activity. How do I read from the SDcard and put them as backgrounds?

Thanks


Right Found the answer! I am using a LinearLayout

   // Get External Storage Directory
    String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
    LinearLayout li=(LinearLayout)findViewById(R.id.layoutid);
    li.setBackgroundDrawable(Drawable.createFromPath(newFile(sdcard,"/s1bg.jpg").getAbsolutePath()));
0

精彩评论

暂无评论...
验证码 换一张
取 消