现在,当我更改字段并打开另一个扩展列表时,它也会更改字段
我的可扩展列表适配器
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private static final String LOG_TAG = "EXPANDABLE_LIST_ADAPTER_LOG";
private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
Log.i(LOG_TAG,"Child:"+listChildData+" header:"+listDataHeader);
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
Object obj = this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosititon);
Log.i(LOG_TAG,"GroupPos:"+groupPosition+" childPos:"+childPosititon+" EdTex:"+obj);
return obj;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
EditText txtListChild = (EditText) convertView
.findViewById(R.id.lblListItem);
// txtListChild.setText(childText);
txtListChild.setHint(childText);
Log.i(LOG_TAG,"GroupPos:"+groupPosition+" childPos:"+childPosition+" text:"+txtListChild.getText());
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
String groupS = this._listDataHeader.get(groupPosition);
int size =this._listDataChild.get(groupS)
.size();
Log.i(LOG_TAG,"Group:"+groupS+" grouppos:"+groupPosition+" size:"+size );
return size;
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
我还意识到,当打开键盘时,它会删除字段,或使其消失,就像正在创建EditTexts.
的另一个实例
第一个问题是通过将稳定的id设置为true来解决的,我发现如果有人愿意关联问题,这可能会有用
@Override
public boolean hasStableIds() {
return true;
}