为什么扫描后有显示不出来的
为什么扫描后有显示不出来的
为什么扫描后有显示不出来的
2015-09-07
package com.example.test;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.example.test.imageloader.imageloader;
import com.example.test.imageloader.imageloader.Type;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
public class ImageAdapter extends BaseAdapter
{
private static Set<String>mSeletedImg=new HashSet<String>();
private String mDirpath;
private List<String>mImgPaths;
private LayoutInflater mInflater;
public ImageAdapter(Context context,List<String> mDatas,String dirPath)
{
this.mDirpath=dirPath;
this.mImgPaths=mDatas;
mInflater=LayoutInflater.from(context);
}
@Override
public int getCount() {
return mImgPaths.size();
}
@Override
public Object getItem(int position) {
return mImgPaths.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
final ViewHolder viewHolder;
if(convertView==null)
{
convertView=mInflater.inflate(R.layout.item_gridview, parent,false);
viewHolder=new ViewHolder();
viewHolder.mImg=(ImageView) convertView.findViewById(R.id.id_item_image);
viewHolder.mSelect=(ImageButton) convertView.findViewById(R.id.id_item_select);
convertView.setTag(viewHolder);
}
else {
viewHolder=(ViewHolder) convertView.getTag();
}
//重置状态
viewHolder.mImg.setImageResource(R.drawable.plugin_camera_no_pictures);
viewHolder.mImg.setColorFilter(null);
Log.e("shuju","a111"+mDirpath+"/"+mImgPaths.get(position));
imageloader.getInstance(3,Type.LIFO).loadImage(mDirpath+"/"+mImgPaths.get(position), viewHolder.mImg);
final String filePath=mDirpath+"/"+mImgPaths.get(position);
viewHolder.mImg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//已经被选择
if(mSeletedImg.contains(filePath))
{
mSeletedImg.remove(filePath);
viewHolder.mImg.setColorFilter(null);
viewHolder.mSelect.setVisibility(View.GONE);
}else//未选择
{
mSeletedImg.add(filePath);
viewHolder.mImg.setColorFilter(Color.parseColor("#77000000"));
viewHolder.mSelect.setVisibility(View.VISIBLE);
}
//notifyDataSetChanged();
}
});
if(mSeletedImg.contains(filePath))
{
viewHolder.mImg.setColorFilter(Color.parseColor("#77000000"));
viewHolder.mSelect.setVisibility(View.VISIBLE);
}
return convertView;
}
private class ViewHolder
{
ImageView mImg;
ImageButton mSelect;
}
}
举报