------ Solution ---------------------------------------- ----
here as long to fill a url, the return is Drawable object Drawable object can be used directly
/**
* @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;
}
------ Solution ------------------------------------- -------
server requests every time you open the software like pictures, set your background
------ Solution ---------------- ----------------------------
use asynchronous task, from the server to download the pictures stored in sdcard inside, next landing application directly judge sdcard the existence of the picture , does not exist on the red server to download
------ For reference only -------------------------- -------------
Thank you , problem solved.
specifically is what I do:
1. welcome screen layout :
<?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>
default load a welcome picture ;
2. enter the application from the server and then download the image ( if there are pictures to be updated on the server ) and save it to local ;
3. next re-enter the application directly from the local access and display in ImageView controls inside , so if the download fails, at least with the LinearLayout background image show.
没有评论:
发表评论