[英]ExpandableListView GroupView with an EditText Expanded not working
[英]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.