自定义了一个expandablelistview 想要删除其中的子项
list使用remove方法把list中的指定项删除了
11-09 21:04:20.585: I/MainActivity(13557): childData=[{child_text=second}, {child_text=third}]
但是在expandablelistview界面显示中,并没有变化,并且还有list溢出报错
定义部分
private ExpandableListView expandablelistview;
private MyAdapter expandableAdapter;
private String [] groupStr={"第一组","第二组","第三组"};
private String [] childStr={"first","second","third"};
private List> groupData = new ArrayList>();
private List> childData = new ArrayList>();
initData()方法如下:
for(int i=0;i<3;i++){
//给标题赋值
Map curGroupMap=new HashMap();
curGroupMap.put("group_title", groupStr[i]);
groupData.add(curGroupMap);
//给子项赋值
Map curChildMap=new HashMap();
curChildMap.put("child_text", childStr[i]);
childData.add(curChildMap);
}
适配器代码如下:
class MyAdapter extends BaseExpandableListAdapter{
@Override
public Object getChild(int arg0, int arg1) {
// TODO Auto-generated method stub
return childData.get(arg0);
}
@Override
public long getChildId(int arg0, int arg1) {
// TODO Auto-generated method stub
return arg1;
}
@Override
public View getChildView(int arg0, int arg1, boolean arg2, View arg3,
ViewGroup arg4) {
// TODO Auto-generated method stub
if(arg3==null){
LayoutInflater inflater=(LayoutInflater)Main.
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
arg3=inflater.inflate(R.layout.child,null);
}
TextView textview=(TextView)arg3.findViewById(R.id.childtext);
textview.setText(childStr[arg0]);
return arg3;
}
@Override
public int getChildrenCount(int arg0) {
// TODO Auto-generated method stub
return childData.get(arg0).size();
}
@Override
public Object getGroup(int arg0) {
// TODO Auto-generated method stub
return groupData.get(arg0);
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return groupData.size();
}
@Override
public long getGroupId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
@Override
public View getGroupView(int arg0, boolean arg1, View arg2,
ViewGroup arg3) {
// TODO Auto-generated method stub
if(arg2==null){
LayoutInflater inflater=(LayoutInflater)Main.
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
arg2=inflater.inflate(R.layout.group, null);
}
TextView textview=(TextView)arg2.findViewById(R.id.grouptext);
textview.setText(groupStr[arg0]);
return arg2;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isChildSelectable(int arg0, int arg1) {
// TODO Auto-generated method stub
return true;
}
}