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; }
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); }else{ elv.collapseGroup(i); } } } } return self(); }
ExpandableListAdapter ela = elv.getExpandableListAdapter();
ExpandableListView v; [...] final int groupCount = v.getExpandableListAdapter().getGroupCount();
ExpandableListView myExpList= (ExpandableListView) this.view.findViewById(R.id.yourExpListView); ExpandableListAdapter adapter = (ExpandableListAdapter) myExpList.getExpandableListAdapter(); ( (ExpandableListParentClass)adapter.getMParent().get(0) ).getParentChildren().add(object); //(change to get(0) which you parent want to get ) adapter.notifyDataSetChanged(); adapter.notifyDataSetInvalidated();
mExpandableList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v,int groupPosition, int childPosition, long id) { SelectableObject<GPSEscolas> item = (SelectableObject<GPSEscolas>) parent.getExpandableListAdapter().getChild(groupPosition,childPosition); if(!item.isSelected()) item.select(); else item.deselect(); .. })
new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { Object object = parent.getExpandableListAdapter().getGroup(groupPosition); .... .... return true; } }
expandableListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(final ExpandableListView parent, final View view, final int groupPosition, final int childPosition, final long identifier) { final Object childObj = parent.getExpandableListAdapter().getChild(groupPosition, childPosition); if (childObj != null) { // Do your magic } return true; } });
private ExpandableListAdapter getAdapter() { ExpandableListAdapter adapter = listView.getExpandableListAdapter(); assertNotNull("list adapter expected to exist, but was null", adapter); return adapter; } }
exp_list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { String tx = parent.getExpandableListAdapter().getChild(groupPosition, childPosition);// this will return your child Object (i guess String in your case) Toast.makeText(getBaseContext(), tx + " Child Clicked", Toast.LENGTH_SHORT).show(); // Store value in sharedPreferences(); Intent l = new Intent(CategoryActivity.this, AddRecipeActivity.class); startActivity(l); return false; } });
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { CreatePizzaAdapter adapter = (CreatePizzaAdapter) parent.getExpandableListAdapter(); View conv = adapter.getChildviewReferences().get(Integer.toString(groupPosition) + Integer.toString(childPosition)); //now you can find any view and child and do anything return true; } });
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; }
@Override public void onResume() { super.onResume(); assert getView() != null : "ProjectOverdueTasksFragment: getView() returned null"; ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.expandable_list); for (int i = 0; i < lv.getExpandableListAdapter().getGroupCount(); i++) lv.expandGroup(i); } }
@Override public void onResume() { super.onResume(); assert getView() != null : "ProjectInactiveTasksFragment: getView() returned null"; ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.expandable_list); for (int i = 0; i < lv.getExpandableListAdapter().getGroupCount(); i++) lv.expandGroup(i); } }
@Override public void onResume() { super.onResume(); assert getView() != null : "ProjectTaskFragment: getView() returned null"; ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.expandable_list); for (int i = 0; i < lv.getExpandableListAdapter().getGroupCount(); i++) lv.expandGroup(i); } }
@Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { ExpandableListAdapter adapter = parent.getExpandableListAdapter(); MyActivityInfo info = (MyActivityInfo)adapter.getChild(groupPosition, childPosition); LauncherIconCreator.launchActivity(getActivity(), info.component_name); return false; } });
public void run() { final int groupCount = expandableListView.getExpandableListAdapter().getGroupCount(); if (groupCount > 0) { for (int i = 0; i < groupCount - 1; i++) { expandableListView.collapseGroup(i); } // logger.info(">>>> expanding group %s...", groupCount - 1); expandableListView.expandGroup(groupCount - 1); } } });
public void run() { final int groupCount = expandableListView.getExpandableListAdapter().getGroupCount(); if (groupCount > 0) { for (int i = 0; i < groupCount - 1; i++) { expandableListView.collapseGroup(i); } // logger.info(">>>> expanding group %s...", groupCount - 1); expandableListView.expandGroup(groupCount - 1); } } });
void update(@NonNull List<WiFiDetail> wiFiDetails, ExpandableListView expandableListView) { updateGroupBy(); if (isGroupExpandable() && expandableListView != null) { int groupCount = expandableListView.getExpandableListAdapter().getGroupCount(); for (int i = 0; i < groupCount; i++) { WiFiDetail wiFiDetail = getWiFiDetail(wiFiDetails, i); if (expanded.contains(getGroupExpandKey(wiFiDetail))) { expandableListView.expandGroup(i); } else { expandableListView.collapseGroup(i); } } } }
@Test public void testAfterUpdateWithGroupByChannel() { // setup List<WiFiDetail> wiFiDetails = withWiFiDetails(); when(settings.getGroupBy()).thenReturn(GroupBy.CHANNEL); when(expandableListView.getExpandableListAdapter()).thenReturn(expandableListAdapter); when(expandableListAdapter.getGroupCount()).thenReturn(wiFiDetails.size()); // execute fixture.update(wiFiDetails, expandableListView); // validate verify(settings).getGroupBy(); verify(expandableListView).getExpandableListAdapter(); verify(expandableListAdapter).getGroupCount(); assertEquals(GroupBy.CHANNEL, fixture.getGroupBy()); }