     package com.example.ghomi.chapter4_4;
             import java.util.ArrayList;
             import android.app.ExpandableListActivity;
             import android.content.Context;
             import android.os.Bundle;
             import android.view.LayoutInflater;
             import android.widget.ExpandableListView;
             public class MainActivity extends ExpandableListActivity{
             private ArrayList<String> parentItems = new ArrayList<String>();
             private ArrayList<Object> childItems = new ArrayList<Object>();
             @Override
             public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                // this is not really  necessary as
                //  ExpandableListActivity contains an ExpandableList
               // you can use (ExpandableListView) findViewById(R.id.list)

               ExpandableListView expandableList = getExpandableListView();
               expandableList.setDividerHeight(2);
               expandableList.setGroupIndicator(null);
               expandableList.setClickable(true);
               setGroupParents();
               setChildData();
               MyExpandableAdapter adapter = new MyExpandableAdapter(parentItems, childItems);
               adapter.setInflater((LayoutInflater)
               getSystemService(Context.LAYOUT_INFLATER_SERVICE), this);
               expandableList.setAdapter(adapter);
               expandableList.setOnChildClickListener(this);
            }
            public void setGroupParents() {
               parentItems.add("Android");
               parentItems.add("Core Java");
                parentItems.add("Desktop Java");
               parentItems.add("Enterprise Java");
            }
            public void setChildData() {
                // Android
               ArrayList<String> child = new ArrayList<String>();
               child.add("Core");
               child.add("Games");
               childItems.add(child);
              // Core Java
               child = new ArrayList<String>();
               child.add("Apache");
               child.add("Applet");
               child.add("AspectJ");
               child.add("Beans");
               child.add("Crypto");
               childItems.add(child);
               // Desktop Java
               child = new ArrayList<String>();
               child.add("Accessibility");
               child.add("AWT");
               child.add("ImageIO");
               child.add("Print");
               childItems.add(child);
               // Enterprise Java
               child = new ArrayList<String>();
               child.add("EJB3");
               child.add("GWT");
               child.add("Hibernate");
               child.add("JSP");
               childItems.add(child);
            }
  }