<test.com.expandablelistviewdemo.CustomExpandListview //这里不唯一,看你具体把CustomExpandListview放在哪里 android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent"></test.com.expandablelistviewdemo.CustomExpandListview>
private String[] parentSource = {"分类1", "分类2", "分类3", "分类4", "分类5"};
private ArrayList<String> parent = new ArrayList<>();
private Map<String, ArrayList<String>> datas = new HashMap<>();
//种类
for (int i = 0; i < parentSource.length; i++) {
parent.add(parentSource[i]);
}
//给每个种类添加模拟数据
for (int i = 0; i < parent.size(); i++) {
String str = parent.get(i);
ArrayList<String> temp = new ArrayList<>();
for (int j = 0; j < 20; j++) {
temp.add("" + j);
}
datas.put(str, temp);
}
myAdapter = new MyAdapter(this, parent, datas, listview); listview.setAdapter(myAdapter);
listview.setHeaderView(getLayoutInflater().inflate(R.layout.indictor_layout, listview, false));
for (int i = 0; i < parent.size(); i++) {
listview.expandGroup(i);
}
listview.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i1, long l) {
Toast.makeText(MainActivity.this, "点击了第" + (i + 1) + " 类的第" + i1 + "项", Toast.LENGTH_SHORT).show();
return true;
}
}
);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有