Example usage for android.widget ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupClickListener

List of usage examples for android.widget ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupClickListener

Introduction

In this page you can find the example usage for android.widget ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupClickListener.

Prototype

ExpandableListView.OnGroupClickListener

Source Link

Usage

From source file:fyp.samoleary.WildlifePrototype2.NavDrawer.NavDrawer.java

@Override
public void setContentView(final int layoutResID) {
    fullLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_main, null);
    assert fullLayout != null;
    actContent = (FrameLayout) fullLayout.findViewById(R.id.content_frame);
    getLayoutInflater().inflate(layoutResID, actContent, true);
    super.setContentView(fullLayout);

    mTitle = mDrawerTitle = getTitle();/*from w ww.ja va 2  s  .c  om*/

    //String[] navDrawerMenuItems = getResources().getStringArray(R.array.menu_items_array);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    // Get the ListView
    mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer);

    // Preparing List Data
    prepareListDataInit();
    listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
    View imgView = getLayoutInflater().inflate(R.layout.header, null);
    mDrawerList.addHeaderView(imgView);

    // Setting List Adapter
    mDrawerList.setAdapter(listAdapter);

    // Listview on child click listener
    mDrawerList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            selectItem(groupPosition, childPosition);
            return false;
        }
    });

    mDrawerList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            selectGroup(groupPosition);
            return false;
        }
    });

    // set up the drawer's list view with items and click listener
    //mDrawerList.setAdapter(new ArrayAdapter<String>(this,
    //        R.layout.drawer_list_item, navDrawerMenuItems));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            setUpNavDrawer();
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            imgText = (TextView) findViewById(R.id.myImageViewText);
            SharedPreferences settings = getSharedPreferences(LocationUtils.SHARED_PREFERENCES, 0);
            String name = settings.getString("name", "Click to set up Profile");
            imgText.setText(name);
            setUpNavDrawer();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}