Code example for ExpandableListView

Methods: setAdaptersetOnChildClickListenersetOnGroupClickListener

0
     
    private void initFragment() 
    { 
        ViewGroup          root = (ViewGroup)getView(); 
        ExpandableListView list = (ExpandableListView)root.findViewById(android.R.id.list);
        list.setAdapter(new CategoriesListAdapter(getSherlockActivity(), isFilterMode()));
        list.setOnGroupClickListener(this);
        list.setOnChildClickListener(this);
    } 
     
    private boolean isFilterMode() 
    { 
        return getArguments().getInt("mode") == MODE_FILTER;
    } 
     
    // Callbacks ---------------------------------------------------------------------------------- 
     
    public boolean onGroupClick(ExpandableListView list, View v, int groupPos, long id)
    { 
        CategoriesListAdapter      adapter = (CategoriesListAdapter)list.getExpandableListAdapter();
        CategoriesListAdapter.Item item    = (CategoriesListAdapter.Item)adapter.getGroup(groupPos);