布局代码:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    ><TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="图片开始位置"    />    <ImageView     android:id="@+id/img1"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    />    <ImageView     android:id="@+id/img2"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    />    <ImageView     android:id="@+id/img3"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    />    <TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="图片结束位置"    /></LinearLayout>

activity代码:

public class SycLoadImg3 extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);loadImg("http://www.baidu.com/img/baidu_logo.gif",R.id.img1);loadImg("http://img3.cache.netease.com/www/logo/logo_png.png",R.id.img2);loadImg("http://www.iteye.com/images/logo.gif?1308833136",R.id.img3);}Handler handler = new Handler();ExecutorService threadPoll = Executors.newFixedThreadPool(5);private void loadImg(final String url,final int id) {threadPoll.submit(new Runnable() {@Overridepublic void run() {try {final Drawable drawable = ImgManager.getDrawableFromUrl(url);Thread.currentThread().sleep(2000);handler.post(new Runnable() {@Overridepublic void run() {ImageView img = (ImageView)SycLoadImg3.this.findViewById(id);img.setImageDrawable(drawable);}});} catch (Exception e) {e.printStackTrace();}}});}}

更多相关文章

  1. Android 图片侧滑展示RecyclerView简单实用
  2. Eclipse Android 代码自动提示功能
  3. 【Android 应用开发】 Android 相关代码规范 更新中 ...
  4. Android 制作.9.png图片之利用Android 9-patch shadow generator
  5. Android开发常用代码片段(一)
  6. Android有用代码(一)
  7. Android PendingIntent实现原理和代码

随机推荐

  1. Android非UI线程访问UI线程的方法总结
  2. Android实现zip文件压缩及解压缩的方法
  3. Android(安卓)对话框用法
  4. React-Native搭建开发环境-Android-Windo
  5. android studio发布版和测试版证书SHA1获
  6. [Android] Compile a CWM recovery from
  7. Android(安卓)表单模拟,文件上传!
  8. Android三种基本的加载网络图片方式
  9. Android之TabHost
  10. android vm heap 虚拟机堆大小 每个应用