Back to project page android_tutorial_projects.
The source code is released under:
Copyright (c) 2013, Uthcode All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redi...
If you think the Android project android_tutorial_projects listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uthcode.expandablelistview; /*from w ww. j a va 2 s . c o m*/ import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; import android.widget.ExpandableListAdapter; import android.widget.ExpandableListView; public class MainActivity extends ActionBarActivity { SparseArray<Group> groups = new SparseArray<Group>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); createData(); ExpandableListView listView = (ExpandableListView) findViewById(R.id.listView); MyExpandableListAdapter adapter = new MyExpandableListAdapter(this, groups); listView.setAdapter(adapter); } public void createData() { for (int j = 0; j < 5; j++) { Group group = new Group("Test" + j); for (int i = 0; i < 5; i++) { group.children.add("Sub Item" + i); } groups.append(j,group); } } }