android listView 子控件事件错行处理
package com.tailan.moms.adapter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.tailan.moms.activity.ApplicationActivity;
import com.tailan.moms.activity.HiddenDangeActivity;
import com.tailan.moms.activity.PictureViewActivity;
import com.tailan.moms.activity.R;
import com.tailan.moms.activity.workorder.WorkOrderReportActivity;
import com.tailan.moms.common.Communal;
import com.tailan.moms.model.PatrolListData;
import com.tailan.moms.model.PatrolReportBackData;
import com.tailan.moms.model.TaskTemplateDetail;
import com.tailan.moms.tools.LogFile;
import com.tailan.moms.tools.MyGridView;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInte易做图ce;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
public class PatrolAdapter extends BaseAdapter {
private List<TaskTemplateDetail> list = null;
private LayoutInflater inflater;
private Context context = null;
List<PatrolReportBackData> patrolReportBackDatas = null;
public static final int NONE = 0;
public static final int PHOTOHRAPH = 1;// 拍照
public static final int PHOTOZOOM = 2; // 缩放
public static final int PHOTORESOULT = 3;// 结果
public static final String IMAGE_UNSPECIFIED = "image/*";
byte[] bitmapBytes = new byte[1024];
protected String bitPhoto = "";
ApplicationActivity activity;
protected ArrayList<HashMap<String, Object>> imageItem = null;
int index = -1;
protected MyGridView photograph = null;
List<ViewHolderData> holderDatas = null;
//PatrolReportBackData patrolReportBackData = null;
int viewIndex = 0;
boolean changed = true;
public PatrolAdapter(List<TaskTemplateDetail> list,Context context,List<PatrolReportBackData> patrolReportBackDatas,ApplicationActivity activity)
{
this.list = list;
this.context = context;
this.inflater = LayoutInflater.from(context);
this.patrolReportBackDatas = patrolReportBackDatas;
this.activity = activity;
imageItem = new ArrayList<HashMap<String, Object>>();
holderDatas = new ArrayList<ViewHolderData>();
for (int i = 0; i < patrolReportBackDatas.size(); i++) {
String isNormal = patrolReportBackDatas.get(i).getIsNormal();
if(isNormal != null)
{
bitPhoto = patrolReportBackDatas.get(i).getPhotos();
ViewHolderData viewHolderData = new ViewHolderData();
viewHolderData.setPosition(i);
if(isNormal.equals("0"))
viewHolderData.setSpinnerIndex(2);
else if(isNormal.equals("1"))
viewHolderData.setSpinnerIndex(1);
viewHolderData.setDescription(patrolReportBackDatas.get(i).getFinishDesc());
viewHolderData.setStrBitPhoto(bitPhoto);
if(bitPhoto != null)
{
imageItem = new ArrayList<HashMap<String, Object>>();
String[] strImage = bitPhoto.split(",");
for (String string : strImage) {
if(!string.equals(""))
{
Communal.getInstance().saveImage(context, string);
String imagepath = Environment.getExternalStorageDirectory() + "/MOMSPHOTO/" + Communal.getInstance().getImageName();
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true ;
BitmapFactory.decodeFile(imagepath, opts);
opts.inSampleSize = computeSampleSize(opts, - 1 , 80 * 80 );
opts.inJustDecodeBounds = false ;
try {
Bitmap bmp = BitmapFactory.decodeFile(imagepath, opts);
HashMap<String, Object> hashmap = new HashMap<String, Object>();
hashmap.put("ItemImage", bmp);//添加图像资源的ID
hashmap.put("ItemText", Communal.getInstance().getImageName());//按序号做ItemText
imageItem.add(hashmap);
} catch (OutOfMemoryError err) {
}
}
}
viewHolderData.setImageList(imageItem);
}
holderDatas.add(viewHolderData);
}
}
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return list.get(arg0);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
//private List<ViewHolder> holder = new ArrayList<ViewHolder>();
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.i("索引值:", String.valueOf(position));
//final PatrolReportBackData patrolReportBackData = patrolReportBackDatas.get(position);
// viewIndex = position;
index = position;
final ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_list_patrol, null);
viewHolder = new ViewHolder();
viewHolder.id = (TextView)convertView.findViewById(R.id.item_patrol_id_textView);
viewHolder.name = (TextView)convertView.findViewById(R.id.item_patrol_name_textView);
viewHolder.spinner = (Spinner)convertView.findViewById(R.id.item_patrol_whetherAnomaly);
viewHolder.relativeLayout = (RelativeLayout)convertView.findViewById(R.id.item_relativeLayout_patrol_description);
viewHolder.disposeDescription = (EditText)convertView.findViewById(R.id.item_patrol_disposeDescription);
viewHolder.addPicture
补充:移动开发 , Android ,