childView是4个textView组成,GroupView就是一个textView。
本身是3个组,当刷新变成4个组时,出现数组越界
这行代码:info = map11.get(key).get(childPosition);
现在不知道怎么解决数组越界问题,listview的数组越界可以用list.clear()方法,
这个ExpandableListView是第一次用,知道的帮忙下,谢谢了。急用
部分代码如下:
// 设置子item的组件
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
String key = TblbActivity.this.parent1.get(groupPosition);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) TblbActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.elv_child_item, null);
}
Gwzjclzt info = new Gwzjclzt();
info = map11.get(key).get(childPosition);
TextView tv_tb_jcbh = (TextView) convertView
.findViewById(R.id.tv_tb_jcbh);
TextView tv_tb_hphm = (TextView) convertView
.findViewById(R.id.tv_tb_hphm);
TextView tv_tb_hpzl = (TextView) convertView
.findViewById(R.id.tv_tb_hpzl);
TextView tv_tb_jclx = (TextView) convertView
.findViewById(R.id.tv_tb_jclx);
tv_tb_jcbh.setText(info.getJcbh());
tv_tb_hphm.setText(info.getHphm());
tv_tb_hpzl.setText(info.getHpzl());
tv_tb_jclx.setText(info.getJclx());
return convertView;
}
* 刷新ExpandableListView
*/
protected void refreshView() {
for (int z = 0; z < mGwlb_list.size(); z++) {
List<Gwzjclzt> mGwzjclzt1_list = new ArrayList<Gwzjclzt>();
String test5 = mGwlb_list.get(z).getGwmc() + "在检车辆";
parent1.add(test5);
for (int z1 = 0; z1 < mGwzjclzt_list.size(); z1++) {
if ((mGwzjclzt_list.get(z1).getGzzt()).equals(parent1.get(z))) {
mGwzjclzt1_list.add(mGwzjclzt_list.get(z1));
map.put(parent1.get(z), mGwzjclzt1_list);
}
}
// 告诉主线程一个消息错误类型:网络连接失败,内容:"网络连接失败"
Message msg = new Message();
// 消息的代号,是一个int类型
msg.what = UPDATE_UI_TIR;
// 要传递的消息对象
msg.obj = z;
// 利用handler发送消息
mHandler.sendMessage(msg);
}
}
private List<String> parent1 = null;
private Gwzjclzt mGwzjclzt1 = null;
private Map<String, List<Gwzjclzt>> map = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tbcls);
mContext = this;
init();
tbclAdapter = new MyAdapter(getApplicationContext(), parent1, map);
tbcls_list.setAdapter(tbclAdapter);