解决方案 »
- 360如何做到ROOT后监控隐私行为
- sendMessageDelayed 怎么用?
- 在ubuntu eclipse下如何关联android源代码
- Android版本太多,怎么查看各个版本做了哪些修订?
- 关于EditText的getText()
- 安卓程序运行出错 The source attachment does not contain the source for the file
- RelativeLayout与Animation的问题
- Android wifi的一些小问题求解
- ftpclinet 调用 storeFile 上传文件编译报错!!
- 输入emoji表情乱码
- android 网络编程,客户端访问 https 域名服务器的问题
- 有没有办法 可以让程序弹出多个广告窗口?
/**
* @param urlpath
* @return Bitmap
* 根据url获取布局背景的对象
*/
public static Drawable getDrawable(String urlpath){
Drawable d = null;
try {
URL url = new URL(urlpath);
URLConnection conn = url.openConnection();
conn.connect();
InputStream in;
in = conn.getInputStream();
d = Drawable.createFromStream(in, "background.jpg");
// TODO Auto-generated catch block
} catch (IOException e) {
e.printStackTrace();
}
return d;
}
具体我是这样做的:
1.欢迎界面布局:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/app_start" > <ImageView
android:id="@+id/app_start_iv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY" > </ImageView>
</LinearLayout>
默认加载一张欢迎图片;
2.进入应用后再从服务器上下载图片(如果服务器上有图片要更新)并保存到本地;
3.下次再进入应用直接从本地获取并展示在ImageView控件里,这样如果下载失败的话,至少会用LinearLayout的背景图展示。