本文实例为大家分享了ExpandableListView使用示例,供大家参考,具体内容如下

MainActivity:
public class Expandable_test extends Activity {
private ExpandableListView listView;
private Map> dataset = new HashMap<>();
private String[] parentList = new String[]{"第一个菜单", "第二个菜单"};
private ExpandableListViewAdpter adpter;
private Context mContext = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_expandable_test);
listView=(ExpandableListView)findViewById(R.id.expandableListViewtext);
adpter=new ExpandableListViewAdpter(this,parentList);
listView.setAdapter(adpter);
}
}