zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    RN常用布局和CSS
    RN常用组件
    海屯天地技术服务支持
    微前端应用解决方案
    React组件复用方式
    Webpack-CodeSplit(按需加载)
    Webpack-CodeSplit(静态文件篇)
    Webpack抽离第三方类库以及common解决方案
    Javascript十六种常用设计模式
    React hooks详解
  • 原文地址:https://www.cnblogs.com/changyiqiang/p/7170129.html
Copyright © 2011-2022 走看看