Expandable list view move group icon indicator to right in jellyBean 4.3 version?
Asked Answered
T

2

9

The below method is not working in android version jellybean 4.3.

historyExpaLV.setIndicatorBounds(historyExpaLV.getRight() - 60,
                    historyExpaLV.getWidth() - 8);    

Does anyone know the solution? Thanks in advance.

Togliatti answered 1/8, 2013 at 13:30 Comment(3)
"not working" is not a very useful explanation of your symptoms.Aquamarine
Does it work in previous versions? Are you calling it before it's measured? More detail, please.Ashwin
yes it is working in previous versions Geobits.Togliatti
C
31

How I fixed this:

Update SDK Manager to Android 4.3 and use it as build target. They introduced a new method in the API 18, called setIndicatorBoundsRelative(int, int), which works as the other (but correctly) in android 4.3.

Make a check for Android version and use the old method with older API:

if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
   mListView.setIndicatorBounds(myLeft, myRight);
} else {
   mListView.setIndicatorBoundsRelative(myLeft, myRight);
}
Colorist answered 2/8, 2013 at 9:48 Comment(4)
but why was this change made ?Osculum
What is myLeft, myRight ? Please elaborate itWilling
myLeft and myRight are your desired values how you want to pad the indicator. They are called "my" because it's up to you to decide what you want them to be. Check out the docs: developer.android.com/reference/android/widget/…, int)Colorist
A cleaner solution at #21706731Mercaptopurine
Y
5

i think it's bug

int right = (int) (getResources().getDisplayMetrics().widthPixels - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics()));
    expandableListView.setIndicatorBounds(right - getResources().getDrawable(R.drawable.group_indicator_padding).getIntrinsicWidth(), right);

this code works fine up to 4.2.2 and do nothing on 4.3

Yoicks answered 1/8, 2013 at 14:20 Comment(2)
Thanks for your kind answer...Which is solved my group indicator image size statically...Machutte
Above answer will work for you. As setIndicatorBoundsRelative will work for Android >= 4.3Gluck

© 2022 - 2024 — McMap. All rights reserved.