Change expandable indicator in ExpandableListView

expandable listview <ExpandableListView android:id=”@+id/expandable_list” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:groupIndicator=”@drawable/group_indicator” android:transcriptMode=”alwaysScroll” /> setindicator here iam useing setindicator code like this this working nice DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; mExpandableList = (ExpandableListView)findViewById(R.id.expandable_list); mExpandableList.setIndicatorBounds(width – GetPixelFromDips(50), width – GetPixelFromDips(10)); public int GetPixelFromDips(float pixels) { // Get the screen’s density scale final float scale = getResources().getDisplayMetrics().density; … Read more

Android ExpandableListView – Looking for a tutorial [closed]

Create item list List<ParentItem> itemList = new ArrayList<ParentItem>(); ParentItem parent1 = new ParentItem(); parent1.getChildItemList().add(new ChildItem()); parent1.getChildItemList().add(new ChildItem()); parent1.getChildItemList().add(new ChildItem()); ParentItem parent2 = new ParentItem(); parent2.getChildItemList().add(new ChildItem()); parent2.getChildItemList().add(new ChildItem()); parent2.getChildItemList().add(new ChildItem()); itemList.add(parent1); itemList.add(parent2); ExpandableListViewAdapter adapter = new ExpandableListViewAdapter(context, itemList); Data Objects public class ParentItem { private List<ChildItem> childItemList; public ParentItem() { childItemList = new ArrayList<ChildItem>(); } … Read more

Programmatically collapse a group in ExpandableListView

Try putting this in your ExpandableListAdapter, listView is a reference to the ExpandableListView itself. And lastExpandedGroupPosition is a integer member variable defined inside your ExpandableListAdapter. @Override public void onGroupExpanded(int groupPosition){ //collapse the old expanded group, if not the same //as new group to expand if(groupPosition != lastExpandedGroupPosition){ listView.collapseGroup(lastExpandedGroupPosition); } super.onGroupExpanded(groupPosition); lastExpandedGroupPosition = groupPosition; }

ExpandableListView -UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

Seems like Adapterview does not allow adding new view, I encountered same problem Solve it by replacing following line convertView = inflator.inflate(R.layout.child_rows, parent); to convertView = inflator.inflate(R.layout.child_rows, null); UPDATE Instead of not using a parent at all, you should simply tell the Inflater not to attach the inflated view to the parent with convertView = … Read more

Collapse all group except selected group in expandable listview android

Have the current expanded group position stored in a variable. In onGroupExpanded do the following. private int lastExpandedPosition = -1; private ExpandableListView lv; //your expandable listview … lv.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { if (lastExpandedPosition != -1 && groupPosition != lastExpandedPosition) { lv.collapseGroup(lastExpandedPosition); } lastExpandedPosition = groupPosition; } });

Expandable list view move group icon indicator to right

setIndicatorBounds(int, int) does not work properly for Android 4.3. They introduced a new method setIndicatorBoundsRelative(int, int) which works ok for 4.3. @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { mExpandableListView.setIndicatorBounds(myLeft, myRight); } else { mExpandableListView.setIndicatorBoundsRelative(myLeft, myRight); } }

Expand all children in expandable list view

You can expand it in getGroupView in your custom adapter: @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); ExpandableListView mExpandableListView = (ExpandableListView) parent; mExpandableListView.expandGroup(groupPosition); return v; } Gluck!