多选框这个时候使用其空间选择事件是不太好处理的
package com.enmu.sun.until.mypbulic;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.enmu.sfh.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
public class MyListAdapter extends BaseAdapter {
private Context context;
private ArrayList
private LayoutInflater Inflater;
private Holder holder;
public static Map
public final class Holder {
// 选择
public CheckBox choose;
public TextView id; // 订单号
public TextView ware; // 商品名
public TextView menoy; // 金额
public TextView person; // 联系人
public TextView time; // 时间
public TextView address; // 地址
}
public MyListAdapter(Context context,
ArrayList
this.mAppList = appList;
this.context = context;
Inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
isSelected = new HashMap
for (int i = 0; i < mAppList.size(); i++) {
isSelected.put(i, false);
}
}
public void setValue(int i) {
isSelected.put(i, false);
}
/**
* 界面调整
*
* @param position
*/
public void gotoActiivity(int position) {
InputMethodManager imm = (InputMethodManager) this.context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
public int getCount() {
return mAppList.size();
}
// 移除
public void removeItem(int position) {
mAppList.remove(position);
this.notifyDataSetChanged();
}
public Object getItem(int position) {
// return mAppList.get(position);
return null;
}
public long getItemId(int position) {
// return position;
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView != null) {
holder = (Holder) convertView.getTag();
} else {
holder = new Holder();
convertView = Inflater.inflate(R.layout.carlistmenu, null);
holder.choose = (CheckBox) convertView
.findViewById(R.id.choose_checkBox1);
holder.id = (TextView) convertView
.findViewById(R.id.car_id_textView);
holder.ware = (TextView) convertView
.findViewById(R.id.car_ware_textView);
holder.menoy = (TextView) convertView
.findViewById(R.id.car_menoy_textView);
holder.person = (TextView) convertView
.findViewById(R.id.car_person_textView);
holder.time = (TextView) convertView
.findViewById(R.id.car_time_textView);
holder.address = (TextView) convertView
.findViewById(R.id.car_address_textView);
holder.choose.setChecked(isSelected.get(position));
convertView.setTag(holder);
}
HashMap
if (appInfo != null) {
String id = (String) appInfo.get("id");
String ware = (String) appInfo.get("ware");
String menoy = (String) appInfo.get("menoy");
String person = (String) appInfo.get("person");
String time = (String) appInfo.get("time");
String adress = (String) appInfo.get("address");
holder.id.setText(id);
holder.ware.setText(ware);
holder.menoy.setText(menoy);
holder.person.setText(person);
holder.time.setText(time);
holder.address.setText(adress);
holder.choose.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
int size = position;
boolean fool = !isSelected.get(size);
isSelected.put(size, fool);
}
});
if (isSelected.get(position)) {
holder.choose.setChecked(true);
} else {
holder.choose.setChecked(false);
}
}
return convertView;
}
}