listview适配器中的控件的点击事件并传值
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = View.inflate(mContext,
R.layout.far_plan_scheme_manager_items, null);
vHolder = new ViewHolder();
vHolder.tvGhouseName = (TextView) convertView
.findViewById(R.id.tv_ghouse_name);// 大鹏名称
vHolder.tvPlanName = (TextView) convertView
.findViewById(R.id.tv_plan_name);// 计划名称
vHolder.tvCategoryDefine = (TextView) convertView
.findViewById(R.id.tv_crop_category_define);// 种植作物
vHolder.tvPlantdate = (TextView) convertView
.findViewById(R.id.tv_plan_plantdate);// 种植时间
vHolder.lLDetails = (LinearLayout) convertView
.findViewById(R.id.ll_details);
convertView.setTag(vHolder);
vHolder.lLDetails.setTag(position);
} else {
vHolder = (ViewHolder) convertView.getTag();
}
//planObj = getItem(position);
planObj=planschemeList.get(position);
String ghouseName = TextUtils.isEmpty(planObj.getGhouseFullname()) ? ""
: planObj.getGhouseFullname();
String planName = TextUtils.isEmpty(planObj.getPlanFullname()) ? ""
: planObj.getPlanFullname();
String categoryDefine = TextUtils.isEmpty(planObj.getCropCategoryDefine()) ? "" : planObj
.getCropCategoryDefine();
long plandateStart = planObj.getPlanPlantdateStart();
long plandateEnd = planObj.getPlanPlantdateEnd();
vHolder.tvGhouseName.setText(ghouseName);
vHolder.tvPlanName.setText(planName);
vHolder.tvCategoryDefine.setText(categoryDefine);
vHolder.tvPlantdate.setText(String.valueOf(plandateStart) + "~"
+ String.valueOf(plandateEnd));
//
//设置点击监听
vHolder.lLDetails.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String planId =planschemeList.get(position).getId();//种植计划ID
Log.i("xxxxxxxxxplanId", planId+"");
Intent intent=new Intent(mContext,FarmingPlanAddActivity.class);
intent.putExtra("planId", planId);//种植计划ID
intent.putExtra("planaddedit", "planedit");//编辑标识符
mContext.startActivity(intent);
}
});
return convertView;
}
static final class ViewHolder {
private TextView tvGhouseName, tvPlanName, tvCategoryDefine,
tvPlantdate;
private LinearLayout lLDetails;
}