• 大小: 2.87M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-01-25
  • 语言: Java
  • 标签: 图片  网络  

资源简介

package com.hsx.imageloader.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hsx.imageloader.listener.AnimateFirstDisplayListener;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.hsx.imageloader.R;

public class ItemAdapter extends BaseAdapter {
DisplayImageOptions options;

private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener();

String[] imageUrls;
Context context;

public ItemAdapter(String[] imageUrls, Context context) {
super();
this.imageUrls = imageUrls;
this.context = context;
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher)//设置图片在下载期间显示的图片
.showImageForEmptyUri(R.drawable.ic_launcher)//设置图片Uri为空或是错误的时候显示的图片
.showImageOnFail(R.drawable.ic_launcher)//设置图片加载/解码过程中错误时候显示的图片
.cacheInMemory(true)//是否緩存都內存中
.cacheOnDisc(true)//是否緩存到sd卡上
.displayer(new RoundedBitmapDisplayer(20))
.build();
}

private class ViewHolder {
public TextView text;
public ImageView image;
}

@Override
public int getCount() {
return imageUrls.length;
}

@Override
public Object getItem(int position) {
return position;
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_list_image, parent, false);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.image = (ImageView) convertView.findViewById(R.id.image);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}

holder.text.setText("Item " (position 1));
// ImageLoader
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(imageUrls[position], holder.image, options, animateFirstListener);

return convertView;
}
}

资源截图

代码片段和文件信息

package com.hsx.imageloader;

import android.app.Application;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

// This configuration tuning is custom. You can tune every option you may tune some of them 
// or you can create default configuration by
//  ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.threadPriority(Thread.NORM_PR

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-03-05 09:58  UniversalImageLoader\
     文件        1124  2015-03-05 08:43  UniversalImageLoader\AndroidManifest.xml
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\
     文件        1124  2015-03-05 08:43  UniversalImageLoader\bin\AndroidManifest.xml
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\
     文件     1168568  2015-03-05 08:43  UniversalImageLoader\bin\classes.dex
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\adapter\
     文件         797  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\adapter\ItemAdapter$ViewHolder.class
     文件        4021  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\adapter\ItemAdapter.class
     文件         347  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\BuildConfig.class
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\data\
     文件         454  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\data\Constants$Config.class
     文件         604  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\data\Constants$Extra.class
     文件        4033  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\data\Constants.class
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\listener\
     文件        1436  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\listener\AnimateFirstDisplayListener.class
     文件        2078  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\MyApplication.class
     文件         343  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$attr.class
     文件         464  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$dimen.class
     文件         410  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$drawable.class
     文件         581  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$id.class
     文件         636  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$layout.class
     文件         391  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$menu.class
     文件         475  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$string.class
     文件         434  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R$style.class
     文件         683  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\R.class
     目录           0  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\view\
     文件        1479  2015-03-05 08:43  UniversalImageLoader\bin\classes\com\hsx\imageloader\view\ImageListActivity.class
............此处省略84个文件信息

评论

共有 条评论