预览加载中,请您耐心等待几秒...
1/4
2/4
3/4
4/4

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

packagecom.down; importjava.io.IOException; importjava.io.InputStream; importjava.lang.ref.SoftReference; importjava.net.MalformedURLException; importjava.net.URL; importjava.util.HashMap; importandroid.app.Activity; importandroid.graphics.drawable.Drawable; importandroid.os.Bundle; importandroid.os.Handler; importandroid.os.Message; importandroid.view.View; importandroid.widget.ImageView; //importcom.down.AsyncImageLoader.ImageCallback; //异步加载 publicclassLazyLoadImageActivityextendsActivity{ AsyncImageLoaderasyncImageLoader; StringimageUrl; Callbackimgcallback; Drawabledrawable; android.widget.ImageViewimageView1; android.widget.ImageViewimageView2; android.widget.ImageViewimageView3; AsyncImageLoaderloder; Stringpath="http://192.168.1.66:8080/downPicService/DownPicServlet"; Stringimgpath; Stringstr; HashMap<String,SoftReference<Drawable>>hashmap; publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); hashmap=newHashMap<String,SoftReference<Drawable>>(); imageView1=(android.widget.ImageView)this.findViewById(R.id.image1); imageView2=(android.widget.ImageView)this.findViewById(R.id.image2); imageView3=(android.widget.ImageView)this.findViewById(R.id.image3); } publicvoidbtn1(Viewv){ imgpath=receive(path); loadImage(imgpath,R.id.image1); } publicvoidbtn2(Viewv){ imgpath=receive(path); loadImage(imgpath,R.id.image2); } publicvoidbtn3(Viewv){ imgpath=receive(path); loadImage(imgpath,R.id.image3); } //从服务端得到图片地址url publicvoidloadImage(Stringurl,intid){ loder=newAsyncImageLoader(); ImageViewimageView=(ImageView)this.findViewById(id); callback=newCallbackimg(imageView); Drawabledrawable=loder.loadDrawable(url); if(drawable!=null){ imageView.setImageDrawable(drawable); } } publicStringreceive(Stringpath){ try{ //服务器Url对象 java.net.URLurl=newjava.net.URL(path); java.net.HttpURLConnectionhttpConnection=(java.net.HttpURLCo