我在GroupView中创建了一个带有EditText的ExpandableListView。 是否有人知道如何保存(维护)GroupView的EditText值?
答案 0 :(得分:0)
它的原理相同
//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());
@覆盖 public View getGroupView(final int groupPosition,boolean isExpanded, 查看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();
}
});
}
您可以在上面的评论中详细了解该帖子