List of usage examples for android.widget ExpandableListView getExpandableListAdapter
public ExpandableListAdapter getExpandableListAdapter()
From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java
private void setListViewHeight(ExpandableListView listView, int group) { ExpandableListAdapter listAdapter = listView.getExpandableListAdapter(); if (mDefaultHeight == 0) mDefaultHeight = listView.getHeight(); int totalHeight = 0; int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.EXACTLY); for (int i = 0; i < listAdapter.getGroupCount(); i++) { if (((listView.isGroupExpanded(i)) && (i != group)) || ((!listView.isGroupExpanded(i)) && (i == group))) { for (int j = 0; j < listAdapter.getChildrenCount(i); j++) { View listItem = listAdapter.getChildView(i, j, false, null, listView); listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED); totalHeight += listItem.getMeasuredHeight(); }/*from ww w . j a v a 2 s . com*/ totalHeight += mDefaultHeight; } } ViewGroup.LayoutParams params = listView.getLayoutParams(); int height = totalHeight + (listView.getDividerHeight() * (listAdapter.getGroupCount() - 1)); if (height < mDefaultHeight) height = mDefaultHeight; params.height = height; listView.setLayoutParams(params); listView.requestLayout(); }
From source file:com.massivcode.androidmusicplayer.activities.MainActivity.java
@Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { switch (parent.getId()) { // ? ? ? ?? ? ? ? ??. // ? ? ? ??? case R.id.artist_ExlistView: { Cursor parentData = (Cursor) parent.getExpandableListAdapter().getGroup(groupPosition); String artist = parentData.getString(parentData.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST)); ArrayList<Long> list = MusicInfoLoadUtil.getArtistTrackInfoList(MainActivity.this, artist); Intent intent = new Intent(MainActivity.this, MusicService.class); intent.setAction(MusicService.ACTION_PLAY); intent.putExtra("list", list); intent.putExtra("position", childPosition); startService(intent);//from w w w.ja v a 2s. c om break; } case R.id.playlist_listView: { Cursor parentData = (Cursor) parent.getExpandableListAdapter().getGroup(groupPosition); parentData.moveToPosition(groupPosition); String playlistName = parentData.getString( parentData.getColumnIndexOrThrow(MyPlaylistContract.MyPlaylistEntry.COLUMN_NAME_PLAYLIST)); ArrayList<Long> list = MusicInfoLoadUtil.getMusicIdListFromPlaylistName(playlistName, getApplicationContext()); Intent intent = new Intent(MainActivity.this, MusicService.class); intent.setAction(MusicService.ACTION_PLAY); intent.putExtra("list", list); intent.putExtra("position", childPosition); startService(intent); break; } } return false; }
From source file:com.granita.tasks.TaskListFragment.java
private void selectChildView(ExpandableListView expandLV, int groupPosition, int childPosition, boolean force) { if (groupPosition < mAdapter.getGroupCount() && childPosition < mAdapter.getChildrenCount(groupPosition)) { // a task instance element has been clicked, get it's instance id and notify the activity ExpandableListAdapter listAdapter = expandLV.getExpandableListAdapter(); Cursor cursor = (Cursor) listAdapter.getChild(groupPosition, childPosition); if (cursor == null) { return; }/*from ww w . j av a 2 s . c o m*/ // TODO: for now we get the id of the task, not the instance, once we support recurrence we'll have to change that Long selectTaskId = cursor.getLong(cursor.getColumnIndex(Instances.TASK_ID)); if (selectTaskId != null) { // Notify the active callbacks interface (the activity, if the fragment is attached to one) that an item has been selected. // TODO: use the instance URI one we support recurrence Uri taskUri = ContentUris.withAppendedId(Tasks.getContentUri(mAuthority), selectTaskId); mCallbacks.onItemSelected(taskUri, force, mInstancePosition); } } }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
public T expand(boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; ExpandableListAdapter ela = elv.getExpandableListAdapter(); if (ela != null) { int count = ela.getGroupCount(); for (int i = 0; i < count; i++) { if (expand) { elv.expandGroup(i);// w w w .j av a2 s. c o m } else { elv.collapseGroup(i); } } } } return self(); }
From source file:com.money.manager.ex.home.MainActivity.java
private void createExpandableDrawer() { UIHelper uiHelper = new UIHelper(this); int iconColor = uiHelper.getSecondaryTextColor(); // Menu.//from ww w . 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:com.androidquery.AQuery.java
public AQuery expand(boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; ExpandableListAdapter ela = elv.getExpandableListAdapter(); if (ela != null) { int count = ela.getGroupCount(); for (int i = 0; i < count; i++) { if (expand) { elv.expandGroup(i);//from w w w . j ava 2 s. co m } else { elv.collapseGroup(i); } } } } return self(); }
From source file:com.androidquery.AbstractAQuery.java
public T expand(boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; ExpandableListAdapter ela = elv.getExpandableListAdapter(); if (ela != null) { int count = ela.getGroupCount(); for (int i = 0; i < count; i++) { if (expand) { elv.expandGroup(i);/*from ww w.jav a 2 s . com*/ } else { elv.collapseGroup(i); } } } } return self(); }