android.widget.ExpandableListAdapter Java Examples
The following examples show how to use
android.widget.ExpandableListAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetainExpandableListView.java From opentasks with Apache License 2.0 | 6 votes |
public void expandGroups(long[] groupsToExpand) { // this.expandedIds = expandedIds; if (groupsToExpand != null && groupsToExpand.length > 0) { ExpandableListAdapter adapter = getExpandableListAdapter(); if (adapter != null) { for (int i = 0; i < adapter.getGroupCount(); i++) { long id = adapter.getGroupId(i); if (inArray(groupsToExpand, id)) { expandGroup(i); } } } } }
Example #2
Source File: TaskListFragment.java From opentasks with Apache License 2.0 | 6 votes |
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; } Uri taskUri = ContentUris.withAppendedId(Instances.getContentUri(mAuthority), (long) TaskFieldAdapters.TASK_ID.get(cursor)); Color taskListColor = new ValueColor(TaskFieldAdapters.LIST_COLOR.get(cursor)); mCallbacks.onItemSelected(taskUri, taskListColor, force, mInstancePosition); } }
Example #3
Source File: ListViewUtil.java From Social with Apache License 2.0 | 6 votes |
/** * 可扩展listview展开时调用 * * @param listView * @param groupPosition */ public static void setExpandedListViewHeightBasedOnChildren( ExpandableListView listView, int groupPosition) { ExpandableListAdapter listAdapter = listView.getExpandableListAdapter(); if (listAdapter == null) { return; } View listItem = listAdapter.getChildView(groupPosition, 0, true, null, listView); listItem.measure(0, 0); int appendHeight = 0; for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) { appendHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); // Log.d(TAG, "Expand params.height" + params.height); params.height += appendHeight; listView.setLayoutParams(params); }
Example #4
Source File: ListViewUtil.java From Social with Apache License 2.0 | 6 votes |
/** * 可扩展listview收起时调用 * * @param listView * @param groupPosition */ public static void setCollapseListViewHeightBasedOnChildren( ExpandableListView listView, int groupPosition) { ExpandableListAdapter listAdapter = listView.getExpandableListAdapter(); if (listAdapter == null) { return; } View listItem = listAdapter.getChildView(groupPosition, 0, true, null, listView); listItem.measure(0, 0); int appendHeight = 0; for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) { appendHeight += listItem.getMeasuredHeight(); } /*Log.d(TAG, "Collapse childCount=" + listAdapter.getChildrenCount(groupPosition));*/ ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height -= appendHeight; listView.setLayoutParams(params); }
Example #5
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 6 votes |
private ArrayList<Long> getExpandedIds() { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { int length = adapter.getGroupCount(); ArrayList<Long> expandedIds = new ArrayList<Long>(); for(int i=0; i < length; i++) { if(list.isGroupExpanded(i)) { expandedIds.add(adapter.getGroupId(i)); } } return expandedIds; } else { return null; } }
Example #6
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 6 votes |
private ArrayList<Long> getExpandedIds() { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { int length = adapter.getGroupCount(); ArrayList<Long> expandedIds = new ArrayList<Long>(); for(int i=0; i < length; i++) { if(list.isGroupExpanded(i)) { expandedIds.add(adapter.getGroupId(i)); } } return expandedIds; } else { return null; } }
Example #7
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 6 votes |
private ArrayList<Long> getExpandedIds() { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { int length = adapter.getGroupCount(); ArrayList<Long> expandedIds = new ArrayList<Long>(); for(int i=0; i < length; i++) { if(list.isGroupExpanded(i)) { expandedIds.add(adapter.getGroupId(i)); } } return expandedIds; } else { return null; } }
Example #8
Source File: ResultsActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.results_expandablelistview); Gson gson = new Gson(); LinkedHashMap<String, List<String>> groupedStatistics = gson .fromJson(results, new ResultsActivity.LinkedHashMapTypeToken().getType()); // create expandable list view ExpandableListView expandableListView = findViewById(R.id.expandableListView); ExpandableListAdapter expandableListAdapter = new ExpandableListViewAdapter(this, groupedStatistics); expandableListView.setAdapter(expandableListAdapter); // expand the first group by default expandableListView.expandGroup(0); }
Example #9
Source File: DynamicSectionListView.java From dynamiclistview with MIT License | 5 votes |
@Override public void setAdapter(ExpandableListAdapter adapter) { if (!(adapter instanceof BaseSectionAdapter)) { System.err.print("SectionListView need BaseSectionAdapter"); return; } super.setAdapter(adapter); mAdapter = (BaseSectionAdapter) adapter; if (mAlwaysExpanded) { openGroup(); fixOpenedGroup(); } }
Example #10
Source File: RetainExpandableListView.java From opentasks with Apache License 2.0 | 5 votes |
public long[] getExpandedGroups() { ExpandableListAdapter adapter = this.getExpandableListAdapter(); int count = adapter.getGroupCount(); ArrayList<Long> expandedIds = new ArrayList<Long>(); for (int i = 0; i < count; i++) { if (this.isGroupExpanded(i)) { expandedIds.add(adapter.getGroupId(i)); } } return toLongArray(expandedIds); }
Example #11
Source File: ExpandableListActivity.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Provide the adapter for the expandable list. */ public void setListAdapter(ExpandableListAdapter adapter) { synchronized (this) { ensureList(); mAdapter = adapter; mList.setAdapter(adapter); } }
Example #12
Source File: FloatingGroupExpandableListView.java From FloatingGroupExpandableListView with Apache License 2.0 | 5 votes |
@Override public void setAdapter(ExpandableListAdapter adapter) { if(!(adapter instanceof WrapperExpandableListAdapter)) { throw new IllegalArgumentException("The adapter must be an instance of WrapperExpandableListAdapter"); } setAdapter((WrapperExpandableListAdapter) adapter); }
Example #13
Source File: QiniuLabMainActivity.java From qiniu-lab-android with MIT License | 5 votes |
private void inflateExpandableListView() { this.exampleGroupTitleList.add(this .getString(R.string.qiniu_quick_start)); this.exampleGroupTitleList.add(this .getString(R.string.qiniu_simple_upload)); this.exampleGroupTitleList.add(this .getString(R.string.qiniu_advanced_upload)); this.exampleGroupTitleList.add(this .getString(R.string.qiniu_audio_video_play)); this.exampleGroupTitleList.add(this .getString(R.string.qiniu_image_view)); this.exampleGroupTitleList.add(this .getString(R.string.qiniu_system_capture)); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_quick_start_demo))); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_simple_upload_values))); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_advanced_upload_values))); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_video_play))); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_image_view))); this.exampleItemTitleList.add(Arrays.asList(this.getResources() .getStringArray(R.array.qiniu_system_capture))); ExpandableListAdapter exampleListViewAdapter = new ExampleExpandableListAdapter( this, this.exampleGroupTitleList, this.exampleItemTitleList); this.exampleListView.setAdapter(exampleListViewAdapter); OnExampleItemClickListener onExampleItemClickListener = new OnExampleItemClickListener( this); this.exampleListView .setOnChildClickListener(onExampleItemClickListener); }
Example #14
Source File: TreeView.java From TreeView with Apache License 2.0 | 5 votes |
@Override public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); if(adapter instanceof ITreeViewHeaderUpdater) { mUpdater = (ITreeViewHeaderUpdater) adapter; } else { throw new IllegalArgumentException("The adapter must instanceof ITreeViewHeaderUpdater."); } }
Example #15
Source File: AnimatedExpandableListView.java From MaterialDesignSupport with MIT License | 5 votes |
@Override public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); if (adapter instanceof AnimatedExpandableListAdapter) { this.adapter = (AnimatedExpandableListAdapter) adapter; } else { throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter"); } }
Example #16
Source File: AnimatedExpandableListView.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
/** * @see ExpandableListView#setAdapter(ExpandableListAdapter) */ public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); // Make sure that the adapter extends AnimatedExpandableListAdapter if(adapter instanceof AnimatedExpandableListAdapter) { this.adapter = (AnimatedExpandableListAdapter) adapter; this.adapter.setParent(this); } else { throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter"); } }
Example #17
Source File: AnimatedExpandableListView.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
/** * @see ExpandableListView#setAdapter(ExpandableListAdapter) */ public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); // Make sure that the adapter extends AnimatedExpandableListAdapter if (adapter instanceof AnimatedExpandableListAdapter) { this.adapter = (AnimatedExpandableListAdapter) adapter; this.adapter.setParent(this); } else { throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter"); } }
Example #18
Source File: ExpandableListActivity.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Provide the adapter for the expandable list. */ public void setListAdapter(final ExpandableListAdapter adapter) { synchronized (this) { ensureList(); this.adapter = adapter; list.setAdapter(adapter); } }
Example #19
Source File: AnimatedExpandableListView.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * @see ExpandableListView#setAdapter(ExpandableListAdapter) */ public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); // Make sure that the adapter extends AnimatedExpandableListAdapter if (adapter instanceof AnimatedExpandableListAdapter) { this.adapter = (AnimatedExpandableListAdapter) adapter; this.adapter.setParent(this); } else { throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter"); } }
Example #20
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 5 votes |
private void restoreExpandedState(ArrayList<Long> expandedIds) { this.expandedIds = expandedIds; if (expandedIds != null) { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { for (int i=0; i<adapter.getGroupCount(); i++) { long id = adapter.getGroupId(i); if (expandedIds.contains(id)) list.expandGroup(i); } } } }
Example #21
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 5 votes |
private void restoreExpandedState(ArrayList<Long> expandedIds) { this.expandedIds = expandedIds; if (expandedIds != null) { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { for (int i=0; i<adapter.getGroupCount(); i++) { long id = adapter.getGroupId(i); if (expandedIds.contains(id)) list.expandGroup(i); } } } }
Example #22
Source File: RootsFragment.java From FireFiles with Apache License 2.0 | 5 votes |
private void restoreExpandedState(ArrayList<Long> expandedIds) { this.expandedIds = expandedIds; if (expandedIds != null) { ExpandableListView list = mList; ExpandableListAdapter adapter = mAdapter; if (adapter != null) { for (int i=0; i<adapter.getGroupCount(); i++) { long id = adapter.getGroupId(i); if (expandedIds.contains(id)) list.expandGroup(i); } } } }
Example #23
Source File: AnimatedExpandableListView.java From AndroidQuick with MIT License | 5 votes |
/** * @see ExpandableListView#setAdapter(ExpandableListAdapter) */ public void setAdapter(ExpandableListAdapter adapter) { super.setAdapter(adapter); // Make sure that the adapter extends AnimatedExpandableListAdapter if(adapter instanceof AnimatedExpandableListAdapter) { this.adapter = (AnimatedExpandableListAdapter) adapter; this.adapter.setParent(this); } else { throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter"); } }
Example #24
Source File: ExpandableListViewAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public ExpandableListViewAssert hasExpandableListAdapter(ExpandableListAdapter adapter) { isNotNull(); ExpandableListAdapter actualAdapter = actual.getExpandableListAdapter(); assertThat(actualAdapter) // .overridingErrorMessage("Expected expandable list adapter <%s> but was <%s>.", adapter, actualAdapter) // .isSameAs(adapter); return this; }
Example #25
Source File: DynamicSectionListView.java From dynamiclistview with MIT License | 4 votes |
public void getPinnedHeaderState() { if (mMaskView == null) return; int position = getFirstVisiblePosition(); if (position < 0 || getCount() == 0 || (mFixedHeaderView == null ? false : mFixedHeaderView.getVisibility() != View.VISIBLE) || mHideFloatingLabel || getFirstVisiblePosition() == getHeaderViewsCount() - 1) { mMaskViewVisible = false; return; } GroupInfo info = getFirstGroupPosition(); if (info == null) { mMaskViewVisible = true; mMaskView.layout(0, mMaskTopY, mMaskViewWidth, mMaskViewHeight + mMaskTopY); mAdapter.onChangedSection(mMaskView, getPackedPositionGroup(getExpandableListPosition(position)), -256); requestLayout(); return; } int listPosition = info.listPosition; if (((ExpandableListAdapter) mAdapter).getChildrenCount(info.groupPosition) == 0 || !isGroupExpanded(info.groupPosition)) { listPosition++; info.groupPosition++; } View groupSection = getChildAt(listPosition); if (groupSection != null) { int y = 0; int alpha = 0; if (mMaskBottomY >= groupSection.getTop()) { y = groupSection.getTop() - mMaskBottomY; if (groupSection.getTop() != 0 && -y < mMaskViewHeight) { alpha = 255 * (mMaskViewHeight + y) / mMaskViewHeight; if (alpha < 0) alpha = 0; } else alpha = 255; } else { y = 0; alpha = 255; } if (mMaskView.getTop() != y) { if (-y > mMaskViewHeight) { mMaskView.layout(0, mMaskTopY, mMaskViewWidth, mMaskViewHeight + mMaskTopY); mAdapter.onChangedSection(mMaskView, info.groupPosition, 255); } else { int groupPostion = info.groupPosition - 1; if (groupPostion >= 0) { mAdapter.onChangedSection(mMaskView, groupPostion, alpha); } mMaskView.layout(0, mMaskTopY + y, mMaskViewWidth, mMaskViewHeight + y + mMaskTopY); } requestLayout(); } mMaskViewVisible = true; return; } }
Example #26
Source File: DynamicSectionListView.java From dynamiclistview with MIT License | 4 votes |
public void openGroup() { for (int i = 0; i < ((ExpandableListAdapter) mAdapter).getGroupCount(); i++) expandGroup(i); }
Example #27
Source File: BaseExpandableListFragment.java From 4pdaClient-plus with Apache License 2.0 | 4 votes |
private void setListAdapter(ExpandableListAdapter mAdapter) { getListView().setAdapter(mAdapter); }
Example #28
Source File: WrapperExpandableListAdapter.java From FloatingGroupExpandableListView with Apache License 2.0 | 4 votes |
public WrapperExpandableListAdapter(ExpandableListAdapter adapter) { mWrappedAdapter = adapter; }
Example #29
Source File: TaskListFragment.java From opentasks with Apache License 2.0 | 4 votes |
@Override public boolean onFlingEnd(ListView v, View listElement, int pos, int direction) { long packedPos = mExpandableListView.getExpandableListPosition(pos); if (ExpandableListView.getPackedPositionType(packedPos) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { ExpandableListAdapter listAdapter = mExpandableListView.getExpandableListAdapter(); Cursor cursor = (Cursor) listAdapter.getChild(ExpandableListView.getPackedPositionGroup(packedPos), ExpandableListView.getPackedPositionChild(packedPos)); if (cursor != null) { long instanceId = cursor.getLong(cursor.getColumnIndex(Instances._ID)); boolean closed = cursor.getLong(cursor.getColumnIndex(Instances.IS_CLOSED)) > 0; String title = cursor.getString(cursor.getColumnIndex(Instances.TITLE)); // TODO: use the instance URI once we support recurrence Uri taskUri = ContentUris.withAppendedId(Instances.getContentUri(mAuthority), instanceId); if (direction == FlingDetector.RIGHT_FLING) { if (closed) { removeTask(taskUri, title); // we do not know for sure if the task has been removed since the user is asked for confirmation first, so return false return false; } else { return setCompleteTask(taskUri, title, true); } } else if (direction == FlingDetector.LEFT_FLING) { if (closed) { return setCompleteTask(taskUri, title, false); } else { openTaskEditor(taskUri, cursor.getString(cursor.getColumnIndex(Instances.ACCOUNT_TYPE))); return false; } } } } return false; }
Example #30
Source File: MainActivity.java From android-intents with Apache License 2.0 | 4 votes |
private void initViews(List<Group> groups) { ExpandableListAdapter adapter = new ItemsAdapter(this, groups); setListAdapter(adapter); }