[英]Groupview with Edittext in ExpandableListView
I have created an ExpandableListView with an EditText in a GroupView.我在 GroupView 中创建了一个带有 EditText 的 ExpandableListView。 Is there someone who knows how to save(maintain) the EditText values of the GroupView?.有没有人知道如何保存(维护)GroupView 的 EditText 值?。
It the same principle都是一样的原理
//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) { @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();
}
});
} }
you can see in more details the post in my comment above你可以在我上面的评论中看到更详细的帖子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.