更新适配器的可扩展列表子项

时间:2016-09-24 14:20:39

标签: android

在我的ExpandableListAdapter中,子视图包含

  public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
                                 View convertView, ViewGroup parent) {

            View v = convertView;

            ChildElement e= new ChildElement();
            e.childPosition = childPosition;

            if (convertView == null) {

                LayoutInflater mInflater = (LayoutInflater) this._context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                convertView = mInflater.inflate(R.layout.main_list_item, null);


                holder = new ViewHolder();
                holder.itemname = (TextView) convertView.findViewById(R.id.image_icon);
                holder.Save_check = (CheckBox) convertView.findViewById(R.id.checkBox);
                ////holder.Save_check.setTag(childPosition);

                holder.Remarks = (EditText) convertView.findViewById(R.id.remarks);
                holder.Qty = (EditText) convertView.findViewById(R.id.qty);

                holder.Date = (EditText) convertView.findViewById(R.id.date);
                ////holder.Date.setTag(childPosition);
                holder.Time = (EditText) convertView.findViewById(R.id.time);
                ////holder.Time.setTag(childPosition);
                holder.itemname = (TextView) convertView.findViewById(R.id.image_icon);

                holder.Date.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                    showDialog(DATE_DIALOG_ID);
                        globalPosition = holder.ref;
                    }
                });

                convertView.setTag(holder);
            }
            else {
                holder = (ViewHolder) convertView.getTag();
            }
          holder.itemname.setText(getChild(groupPosition, childPosition).toString().toLowerCase());

         return convertView;    
        }

和适配器外部我有一个DatePickerDialog.OnDateSetListener像这样

private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {

        // when dialog box is closed, below method will be called.
        public void onDateSet(DatePicker view, int selectedYear,
                              int selectedMonth, int selectedDay) {
            year = selectedYear;
            month = selectedMonth;
            day = selectedDay;
            String date = (month + 1)+"/"+year;
            holder.Date.setText(date);
        }    
    };

我的问题是,当我选择日期时,它会更新子视图的最后编辑文本,而不是选择编辑文本。

0 个答案:

没有答案