繁体   English   中英

在 ExpandableListView 中带有 Edittext 的 Groupview

[英]Groupview with Edittext in ExpandableListView

我在 GroupView 中创建了一个带有 EditText 的 ExpandableListView。 有没有人知道如何保存(维护)GroupView 的 EditText 值?。

都是一样的原理

//you need to allocate the data structure in size of the amount of items in your list
List<String> _retData = new ArrayList<String>(_data.size());   

@Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

    Holder h = null; //this will hold the edittext instances of eachItem in expand list
    if(convertView==null)
    {
        convertView = LayoutInflater.from(_context).inflate(android.R.layout.simple_expandable_list_item_2,
                parent, false);
        h = new Holder();
        h._editText = (EditText)convertView.findViewById(R.id.edit1);
        convertView.setTag(h);
    }
    else
    {
        h = (Holder)convertView.getTag();
    }

    //saving the data when the user write something... 
    h._editText.addTextChangedListener(new TextWatcher() {

       public void afterTextChanged(Editable s) {}

       public void beforeTextChanged(CharSequence s, int start,
         int count, int after) {
       }

       public void onTextChanged(CharSequence s, int start, int before, int count) {
         _retData.get(groupPosition)._itemPlant = s.toString();
       }
      });

}

你可以在我上面的评论中看到更详细的帖子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM