开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜