Example usage for android.widget ExpandableListView setOnGroupClickListener

List of usage examples for android.widget ExpandableListView setOnGroupClickListener

Introduction

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

Prototype

public void setOnGroupClickListener(OnGroupClickListener onGroupClickListener) 

Source Link

Usage

From source file:dev.drsoran.moloko.fragments.base.MolokoExpandableListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    loaderImpl.onViewCreated(view, savedInstanceState);
    editImpl.onViewCreated(view, savedInstanceState);

    final ExpandableListView expandableListView = getExpandableListView();

    expandableListView.setOnGroupClickListener(this);
    expandableListView.setOnChildClickListener(this);
    expandableListView.setOnGroupCollapseListener(this);
    expandableListView.setOnGroupExpandListener(this);
}

From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.audio_browser, container, false);

    mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.content);
    mFlingViewGroup.setOnViewSwitchedListener(mViewSwitchListener);

    mHeader = (HorizontalScrollView) v.findViewById(R.id.header);
    mHeader.setOnTouchListener(new OnTouchListener() {
        @Override//from   ww  w  .  j  av a 2 s .  c  o  m
        public boolean onTouch(View v, MotionEvent e) {
            // prevent the user from scrolling the header
            return true;
        }
    });

    ListView songsList = (ListView) v.findViewById(R.id.songs_list);
    ExpandableListView artistList = (ExpandableListView) v.findViewById(R.id.artists_list);
    ExpandableListView albumList = (ExpandableListView) v.findViewById(R.id.albums_list);
    ExpandableListView genreList = (ExpandableListView) v.findViewById(R.id.genres_list);

    songsList.setAdapter(mSongsAdapter);
    artistList.setAdapter(mArtistsAdapter);
    albumList.setAdapter(mAlbumsAdapter);
    genreList.setAdapter(mGenresAdapter);

    songsList.setOnItemClickListener(songListener);
    artistList.setOnGroupClickListener(playlistListener);
    albumList.setOnGroupClickListener(playlistListener);
    genreList.setOnGroupClickListener(playlistListener);

    artistList.setOnChildClickListener(playlistChildListener);
    albumList.setOnChildClickListener(playlistChildListener);
    genreList.setOnChildClickListener(playlistChildListener);

    registerForContextMenu(songsList);
    registerForContextMenu(artistList);
    registerForContextMenu(albumList);
    registerForContextMenu(genreList);

    return v;
}

From source file:com.fitme.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.options, menu);
    MenuItem mi = menu.findItem(R.id.menu_spinner_active_program);
    final TextView tv = (TextView) mi.getActionView();
    ActiveProgramDAO apd = new ActiveProgramDAO(MainActivity.this);
    activeProgram = apd.getActiveProgramName();
    tv.setText(activeProgram);/*  w w w.  j  a v a2s .c om*/

    tv.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            final Dialog dialog = new Dialog(MainActivity.this);
            dialog.setTitle(getText(R.string.title_select_prog_dialog));
            View programView = getLayoutInflater().inflate(R.layout.programs_list, null);
            ExpandableListView elv = (ExpandableListView) programView.findViewById(R.id.list_programs);
            final ProgramListAdapter pda = new ProgramListAdapter(MainActivity.this);
            elv.setAdapter(pda);
            // Setting listener for Add Program button
            Button addProgram = (Button) programView.findViewById(R.id.button_add_program);
            addProgram.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    onAddProgramRequested(pda);
                }
            });
            elv.setGroupIndicator(null);
            elv.setOnGroupClickListener(null);
            elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
                @Override
                public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition,
                        int childPosition, long l) {
                    pda.setProgramSelected(groupPosition, childPosition);
                    onNewProgramSelected(pda.getSelectedProgramName());
                    // Refresh trainings section list
                    TrainingsSectionFragment tsf = (TrainingsSectionFragment) mAppSectionsPagerAdapter
                            .getItem(AppSectionsPagerAdapter.SECTION_TRAININGS);
                    tsf.onNewProgramSelected();
                    dialog.dismiss();
                    return false;
                }
            });
            dialog.setContentView(programView);
            dialog.show();
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT);
        }
    });

    return true;
}

From source file:com.money.manager.ex.home.MainActivity.java

private void createExpandableDrawer() {
    UIHelper uiHelper = new UIHelper(this);
    int iconColor = uiHelper.getSecondaryTextColor();

    // Menu./*from  w  ww  .ja v a  2  s  .c o  m*/

    final ArrayList<DrawerMenuItem> groupItems = getDrawerMenuItems();
    final ArrayList<Object> childItems = new ArrayList<>();

    // Home
    childItems.add(null);

    // Open Database. Display the recent db list.
    ArrayList<DrawerMenuItem> childDatabases = getRecentDatabasesDrawerMenuItems();
    childItems.add(childDatabases);

    // Synchronization
    if (new SyncManager(this).isActive()) {
        childItems.add(null);
    }

    // Entities
    ArrayList<DrawerMenuItem> childTools = new ArrayList<>();
    // manage: account
    childTools.add(new DrawerMenuItem().withId(R.id.menu_account).withText(getString(R.string.accounts))
            .withIconDrawable(uiHelper.getIcon(MMXIconFont.Icon.mmx_temple).color(iconColor)));
    // manage: categories
    childTools.add(new DrawerMenuItem().withId(R.id.menu_category).withText(getString(R.string.categories))
            .withIconDrawable(uiHelper.getIcon(MMXIconFont.Icon.mmx_tag_empty).color(iconColor)));
    // manage: currencies
    childTools.add(new DrawerMenuItem().withId(R.id.menu_currency).withText(getString(R.string.currencies))
            .withIconDrawable(uiHelper.getIcon(GoogleMaterial.Icon.gmd_euro_symbol).color(iconColor)));
    // manage: payees
    childTools.add(new DrawerMenuItem().withId(R.id.menu_payee).withText(getString(R.string.payees))
            .withIconDrawable(uiHelper.getIcon(GoogleMaterial.Icon.gmd_group).color(iconColor)));
    childItems.add(childTools);

    // Recurring Transactions
    childItems.add(null);

    // Budgets
    childItems.add(null);

    // Asset Allocation
    //if (BuildConfig.DEBUG) <- this was used to hide the menu item while testing.
    childItems.add(null);

    // Search transaction
    childItems.add(null);

    // reports
    childItems.add(null);

    // Settings
    childItems.add(null);

    // Donate
    childItems.add(null);

    // Help
    childItems.add(null);

    // Adapter.
    final ExpandableListView drawerList = (ExpandableListView) findViewById(R.id.drawerExpandableList);
    DrawerMenuGroupAdapter adapter = new DrawerMenuGroupAdapter(this, groupItems, childItems);
    drawerList.setAdapter(adapter);

    // set listener on item click
    drawerList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (mDrawer == null)
                return false;
            // if the group has child items, do not e.
            ArrayList<String> children = (ArrayList<String>) childItems.get(groupPosition);
            if (children != null)
                return false;

            // Highlight the selected item, update the title, and close the drawer
            drawerList.setItemChecked(groupPosition, true);

            // You should reset item counter
            mDrawer.closeDrawer(mDrawerLayout);
            // check item selected
            final DrawerMenuItem item = (DrawerMenuItem) drawerList.getExpandableListAdapter()
                    .getGroup(groupPosition);
            if (item != null) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        // execute operation
                        onDrawerMenuAndOptionMenuSelected(item);
                    }
                }, 200);
            }
            return true;
        }
    });

    drawerList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            if (mDrawer == null)
                return false;

            mDrawer.closeDrawer(mDrawerLayout);

            ArrayList<Object> children = (ArrayList) childItems.get(groupPosition);
            final DrawerMenuItem selectedItem = (DrawerMenuItem) children.get(childPosition);
            if (selectedItem != null) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        onDrawerMenuAndOptionMenuSelected(selectedItem);
                    }
                }, 200);
                return true;
            } else {
                return false;
            }
        }
    });
}

From source file:org.anurag.file.quest.FileQuestHD.java

private void init_drawer_menu() {
    // TODO Auto-generated method stub
    ExpandableListView drLs = (ExpandableListView) drawer.findViewById(R.id.drawer_menu_list);
    drLs.setAdapter(new drAdpt());
    drLs.setSelector(R.drawable.while_list_selector_hd);

    drLs.setOnGroupClickListener(new OnGroupClickListener() {
        @Override/* w ww .  j a v  a2  s. com*/
        public boolean onGroupClick(ExpandableListView arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            switch (arg2) {
            case 0:
                Intent intent = new Intent(FileQuestHD.this, GraphAnalysis.class);
                startActivity(intent);
                break;

            case 5:
                //checks the new update for file quest....
                update_checker();
                break;
            }
            return false;
        }
    });

    drLs.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2, int arg3, long arg4) {
            // TODO Auto-generated method stub
            String type = null;
            int tweakwhat = 0;
            switch (arg3) {
            case 0:
                tweakwhat = 0;
                type = " favorite ";
                break;

            case 1:
                tweakwhat = 1;
                type = " music ";
                break;

            case 2:
                tweakwhat = 2;
                type = " apps ";
                break;

            case 3:
                tweakwhat = 3;
                type = " photos ";
                break;

            case 4:
                tweakwhat = 4;
                type = " videos ";
                break;

            case 5:
                tweakwhat = 5;
                type = " documents ";
                break;

            case 6:
                tweakwhat = 6;
                type = " archives ";
                break;

            case 7:
                tweakwhat = 7;
                type = " unknown ";
                break;
            }

            new ConfirmTweakTask(FileQuestHD.this, arg2, type, tweakwhat);

            return false;
        }
    });
}