"清单文件中"---><uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
三个权限和在application 标签下配置 android:name=".Applications"
public class MainActivity extends AppCompatActivity {
private ImageView img; String[] images = { "https://img-my.csdn.net/uploads/201407/26/1406383264_8243.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383248_3693.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383243_5120.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383242_3127.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383242_9576.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383242_1721.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383219_5806.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383214_7794.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383213_4418.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383213_3557.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383210_8779.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383172_4577.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383166_3407.jpg", "https://img-my.csdn.net/uploads/201407/26/1406383166_2224.jpg" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); img = (ImageView) findViewById(R.id.imageView); //d得到imageLoaderde 的实例 ImageLoader imageLoader = ImageLoader.getInstance(); new DisplayImageOptions.Builder() //设置鱼片在下载期间显示的图片 .showImageOnLoading(R.mipmap.ic_launcher) //设置图片url路径为空或错误的时候 .showImageForEmptyUri(R.mipmap.ic_launcher) //设置图片加载/解码过程中错误时候显示的图片 .showImageOnFail(R.mipmap.ic_launcher) /* * DisplayImageOptions options; options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_launcher) //设置图片在下载期间显示的图片 .showImageForEmptyUri(R.drawable.ic_launcher)//设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.ic_launcher) //设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)//设置下载的图片是否缓存在内存中 .cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中 .considerExifParams(true) //是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型// .decodingOptions(android.graphics.BitmapFactory.Options decodingOptions)//设置图片的解码配置 //.delayBeforeLoading(int delayInMillis)//int delayInMillis为你设置的下载前的延迟时间 //设置图片加入缓存前,对bitmap进行设置 //.preProcessor(BitmapProcessor preProcessor) .resetViewBeforeLoading(true)//设置图片在下载前是否重置,复位 .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间 .build();/ * */ .build(); imageLoader.displayImage(images[2], img); }}