diegocarloslima / floatinggroupexpandablelistview Goto Github PK
View Code? Open in Web Editor NEWAn open source Android library that provides a floating group view at the top of the ExpandableListView
License: Apache License 2.0
An open source Android library that provides a floating group view at the top of the ExpandableListView
License: Apache License 2.0
I think in certain cases, it would be very useful to float both the top (current) group view and the bottom (next) group view, to indicate that that there may be more sections, and possibly adding a shortcut for larger datasets. It doesn't seem like this should be very difficult to implement (mostly adding an option and duplicating/modifying the drawFloatingGroupIndicator
method to draw at the bottom. I'm just curious if you have any pointers on how to implement that, or would be willing to add that as a feature.
in my prob , i only need sticky header and i want to disable expandable list view header .
Hello!
When GroupView starts to float, convertView passed to the getGroupView method is always null. This affects smoothness of scrolling a lot when View is more complicated then TextView (because it is inflated on each onScroll callback).
First of all thank you very much for this library, but I have an issue with the GroupView. When I download an Image to set on an ImageView in the GroupView, the downloaded Image disappears when I scroll down. When I scroll back to top, the Image is visible again.
Did somebody experience that and has a clue why this keeps happening?
Thanks in regard!
Can not shrink the group when i scroll.
When i have a lots of items the scroll very lagy..
Hi! :-)
We can initialize the FloatingGroupExpandableListView with the listSelector to have list items highlighted on item click. However, that selection is lost after any group (even the group that doesn't hold the tapped item) expand/collapse.
I believe that the item selection should not be lost at group expanding/collapsing because expand/collapse is just a way of data visualization, while the data is the same (e.g. with one selected item).
What do you think about it?
Thanks
I Fix it by adding this line :
if(params == null) {
params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
mFloatingGroupView.setLayoutParams(params);
mFloatingGroupView.setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
}
First thank you for this awesome library :)
I am using three group headers... everything runs fine as long as the middle group header have limited number in number of items. However when the number of items within the second header is large, the other headers are pushed out of the viewing container although we can still scroll and go to that header but, that is not the desired behaviour I was looking for.
Is there a way I can make all the headers stick to their place?
I am using an implementation that doesn't extend from BaseExpandableListAdapter - can it be changed to use the interface rather than a concrete implementation?
Compiled as-is and tried to run on a device with 2.3.4
At a minimum, the manifest should be updated.
i can't access child position class not able to remove or add any child runtime
When I download a dfp image and put it inside adview (the adview i put in the layout of the floating group header) the downloaded dfp disappears when I scroll down. When I scroll back to top, the Image is visible again.
And sometimes clicking on the group expands it and sometimes it doesn not!
help please
there have some problems when use it with SwipeRefreshLayout . for example, when scroll ExpandableListView up, the ExpandableListView have not scroll to the top yet , but has invoke the swipeRefresh action. sorry,my english is poor .
I found this library and it's exactly what I'm looking for. My arrays for header and items are parsed by JSON string, and I have a refresh button on my app. So whenever I press the refresh button, I need to clear the adapter to remove old data and insert new data. But I got the error below:
04-08 16:23:52.151: E/AndroidRuntime(26743): FATAL EXCEPTION: main
04-08 16:23:52.151: E/AndroidRuntime(26743): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
04-08 16:23:52.151: E/AndroidRuntime(26743): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
04-08 16:23:52.151: E/AndroidRuntime(26743): at java.util.ArrayList.get(ArrayList.java:308)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.pnminh.dfytask.adapter.ExpandableListAdapter.getChildrenCount(ExpandableListAdapter.java:94)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.diegocarloslima.fgelv.lib.WrapperExpandableListAdapter.getChildrenCount(WrapperExpandableListAdapter.java:49)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.drawFloatingGroupIndicator(FloatingGroupExpandableListView.java:446)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.dispatchDraw(FloatingGroupExpandableListView.java:171)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14856)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.widget.AbsListView.draw(AbsListView.java:5051)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13744)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14856)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13744)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13739)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14856)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.support.v4.view.ViewPager.draw(ViewPager.java:2171)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13744)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13739)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13739)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14563)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.draw(View.java:14856)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.widget.FrameLayout.draw(FrameLayout.java:467)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2621)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13744)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.View.getDisplayList(View.java:13786)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1411)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1359)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2677)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2541)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2156)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1251)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6379)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.Choreographer.doFrame(Choreographer.java:561)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.os.Handler.handleCallback(Handler.java:730)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.os.Handler.dispatchMessage(Handler.java:92)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.os.Looper.loop(Looper.java:137)
04-08 16:23:52.151: E/AndroidRuntime(26743): at android.app.ActivityThread.main(ActivityThread.java:5493)
04-08 16:23:52.151: E/AndroidRuntime(26743): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 16:23:52.151: E/AndroidRuntime(26743): at java.lang.reflect.Method.invoke(Method.java:525)
04-08 16:23:52.151: E/AndroidRuntime(26743): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit
Could you walk me through this problem? Thank you very much
Hi Diego, thanks for your library! :-)
Seems there is a little issue with groups drawing as pinned.
Simple scenario to reproduce:
Look at the attached image.
"MORE" is the 2nd group. And you can see a small piece of the 1st group bottom.
Tap anywhere inside the read area will expand the 1st group, even if visually you tap on the 2nd group.
Red arrow points to the area which will invoke 1st group reaction, green arrow - 2nd group. Notice, that buggy area has height equal to group height.
So seems your library forgets to draw the 1st group as pinned (it should be pinned because it was moved to the top after the 2nd group expand at step 2), but thinks that it's here at reacts on taps appropriately.
What do you think about it?
Hi,
happy new Year, too! And thanks for fixing bug #2 and #3. And now I can report the nect little bug: click-animations to views in the currentFloatingGroup are not supported and there is no click animation if you expand/collapse the current floating group. In your example activity the floating groups have usually a yellow background if they are clicked, but the floating group doesn't have this
Hello.
On Android API 10 there is no field "positionSelector" in ExpandableListView class, so reflection doesn't work. There is no error, but there is a warning in log (see positionSelectorOnFloatingGroup method).
Anyway, this is a great library I was looking for!
Regards.
I have an requirement to make all the headers sticky on top when items are scrolled. The current implementation just makes only one header sticky and pulls it when other header comes to the top. Any idea on how make all the headers sticky.
Hi,
My app is crashing on scrolling the list in emulator and some Sony Ericsson devices. I found that the crash started coming after this commit 1e3f7b0
According to the error logs, the crash is because of a NullPointerException in RelativeLayout.onMeasure
- which is called by mFloatingGroupView.measure(childWidthSpec, childHeightSpec);
Hi, I just discovered your library and I must say it is amazing!
One bug I found (except for the reflection errors in older API versions other people have mentioned) is that the first group header in my list does not expand when clicked (all other groups work well and as expected).
I have tried debugging the matter and it should not be happening, since the click is not dispatched to the floating group (as it shouldn't be) and it is passed to super.discpatchTouchEvent().
It seems that the floating header is actually picking up the click somehow, though.
Maybe it has something to do with my headers layout (they are simple horizontal linear layouts with android:clickable=false, having a textview and a button with a click handler as children).
Any suggestions would be appreciated...
I have described my question completely here
, please have look.
Thank you !
2020-07-24 00:44:21.690 7989-7989/com.KryptosTextApp.KryptosText E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.KryptosTextApp.KryptosText, PID: 7989
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.dispatchDraw(FloatingGroupExpandableListView.java:192)
at android.view.View.draw(View.java:21424)
at android.widget.AbsListView.draw(AbsListView.java:4388)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at androidx.viewpager.widget.ViewPager.draw(ViewPager.java:2426)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1277)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1478)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
2020-07-24 00:44:21.693 7989-7989/com.KryptosTextApp.KryptosText E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
I use your library. If possible add me to the list used. https://play.google.com/store/apps/details?id=com.CallVoiceRecorderFree
Hi Diego, I got NPE whenever I open xml file that contains
<com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
and here is the full log:
java.lang.NullPointerException
Exception details are logged in Window > Show View > Error Log
java.lang.NullPointerException
at android.widget.ExpandableListView.getFlatListPosition(ExpandableListView.java:911)
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.drawDefaultSelector(FloatingGroupExpandableListView.java:458)
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.dispatchDraw(FloatingGroupExpandableListView.java:203)
at android.view.View.draw(View.java:14468)
at android.widget.AbsListView.draw(AbsListView.java:3817)
at android.view.View.draw(View.java:14350)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14348)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14348)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14468)
at android.view.View.draw(View.java:14350)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14348)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14468)
at android.view.View.draw(View.java:14350)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14468)
It's not cause any error in the app but it prevent editing the xml file in graphical.
Hi,
thanks for this nice code. It works fine, if I use a LinearLayout as parent rootView of a group item. If I use a RelativeLayout as parent of a group item there happens something buggy.
1st log:
java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at base.util.ui.listview.ExpandListAdapter.getGroup(ExpandListAdapter.java)
at my.package.Fragment$Adapter.getGroupView(Fragment.java)
at com.diegocarloslima.fgelv.lib.WrapperExpandableListAdapter.getGroupView(WrapperExpandableListAdapter.java)
at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:450)
2nd log:
java.lang.ArrayIndexOutOfBoundsException
at android.view.MotionEvent.getY(MotionEvent.java:934)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:2263)
at android.widget.ListView.onTouchEvent(ListView.java:3492)
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.onTouchEvent(FloatingGroupExpandableListView.java:312)
at android.view.View.dispatchTouchEvent(View.java:3934)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:934)
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.dispatchTouchEvent(FloatingGroupExpandableListView.java:301)
Dear Diego,
great piece of software you have there. It almost worked out of the box for me. The only problem is that the OnChildClickListener
which I had implemented in the same fragment where I also set up your FloatingGroupExpandableListView
does not get called anymore, as it was the case before I used your extension. How would I implement such a listener while using your lib? Thanks for your answer!
Cordially,
CK
Hi,
if the currentFloatingGroup of is collapsed there is a little change in the position of this floatingGroupView, if its on the top of the current list.
you can fix this with replacing the code in FloatingGroupExpandableListView - private void createFloatingGroupView(int firstVisibleFlatPosition) {
int currentFloatingGroupScrollY = 0;
if(nextGroupView != null && nextGroupView.getTop() < getPaddingTop() + mCurrentFloatingGroupView.getMeasuredHeight() + getDividerHeight()) {
currentFloatingGroupScrollY = nextGroupView.getTop() - (getPaddingTop() + mCurrentFloatingGroupView.getMeasuredHeight() + 2 * getDividerHeight());
}
final int left = getPaddingLeft();
final int top = getPaddingTop() + 2 *
getDividerHeight() + currentFloatingGroupScrollY;
final int right = left + mCurrentFloatingGroupView.getMeasuredWidth();
final int bottom = top + mCurrentFloatingGroupView.getMeasuredHeight();
mCurrentFloatingGroupView.layout(left, top, right, bottom);
With
int currentFloatingGroupScrollY = 0;
if(nextGroupView != null && nextGroupView.getTop() < getPaddingTop() + mCurrentFloatingGroupView.getMeasuredHeight() + getDividerHeight()) {
currentFloatingGroupScrollY = nextGroupView.getTop() - (getPaddingTop() + mCurrentFloatingGroupView.getMeasuredHeight() + getDividerHeight());
}
final int left = getPaddingLeft();
final int top = getPaddingTop() + currentFloatingGroupScrollY;
final int right = left + mCurrentFloatingGroupView.getMeasuredWidth();
final int bottom = top + mCurrentFloatingGroupView.getMeasuredHeight();
mCurrentFloatingGroupView.layout(left, top, right, bottom);
Greetings
I want to expand all groups programmatically in onCreate().
This ExpandableListView.expandGroup(0);
is producing a NullPointerException, but I am sure that the group exists.
EDIT: Sorry should have looked up the sample code first, I had to put my code after .setAdapter().
How can i add drop shadow only after child is below the header?
I'ts possible?
Hi, me again
I have another problem with your great lib.
I want to insert another clickable item inside a groupView so if I click somewhere else in the groupView, th groupView expanded/disexpanded. If I click e.g. an image something else should happened. To do so in ordinary expandableListView I insert
android:descendantFocusability="blocksDescendants"
into the groupItem Layout. For example code I used your SampleActivity and modified it a bit.
sample_activity_list_group_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal" >
<ImageView
android:id="@+id/sample_activity_list_group_item_image"
android:layout_width="66dp"
android:layout_height="66dp"
android:layout_gravity="center_vertical"
android:background="#FFA2C955"
android:padding="3dp" />
<RelativeLayout
android:id="@+id/sample_activity_list_group_item_background"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#FFA2C955"
android:orientation="horizontal" >
<TextView
android:id="@+id/sample_activity_list_group_item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textColor="#FFFFFFFF"
android:textSize="20sp" />
<ImageView
android:id="@+id/sample_activity_list_group_expanded_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp" />
</RelativeLayout>
</LinearLayout>
And to do something else I edited the SampleAdapter by imlementing onClick(View v) and adding this as OnClickListener to the ImageView on the left side
SampleAdapter.java:
package com.diegocarloslima.fgelv.sample;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class SampleAdapter extends BaseExpandableListAdapter implements OnClickListener {
private final Context mContext;
private final LayoutInflater mLayoutInflater;
private final String[] mGroups = {
"Cupcake",
"Donut",
"Eclair",
"Froyo",
"Gingerbread",
"Honeycomb",
"Ice Cream Sandwich",
"Jelly Bean",
"KitKat"
};
private final int[] mGroupDrawables = {
R.drawable.cupcaket,
R.drawable.donutt,
R.drawable.eclairt,
R.drawable.froyot,
R.drawable.gingerbreadt,
R.drawable.honeycombt,
R.drawable.ice_cream_sandwicht,
R.drawable.jelly_beant,
R.drawable.kitkatt
};
private final String[][] mChilds = {
{"1.5"},
{"1.6"},
{"2.0","2.0.1","2.1"},
{"2.2","2.2.1","2.2.2","2.2.3"},
{"2.3","2.3.1","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7"},
{"3.0","3.1","3.2","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.2.6"},
{"4.0", "4.0.1", "4.0.2", "4.0.3", "4.0.4"},
{"4.1", "4.1.1", "4.1.2", "4.2", "4.2.1", "4.2.2", "4.3", "4.3.1"},
{"4.4"}
};
public SampleAdapter(Context context) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getGroupCount() {
return mGroups.length;
}
@Override
public Object getGroup(int groupPosition) {
return mGroups[groupPosition];
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null) {
v = mLayoutInflater.inflate(R.layout.sample_activity_list_group_item, null);
}
final ImageView image = (ImageView) v.findViewById(R.id.sample_activity_list_group_item_image);
image.setImageResource(mGroupDrawables[groupPosition]);
image.setOnClickListener(this);
final TextView text = (TextView) v.findViewById(R.id.sample_activity_list_group_item_text);
text.setText(mGroups[groupPosition]);
final ImageView expandedImage = (ImageView) v.findViewById(R.id.sample_activity_list_group_expanded_image);
final int resId = isExpanded ? R.drawable.minus : R.drawable.plus;
expandedImage.setImageResource(resId);
return v;
}
@Override
public int getChildrenCount(int groupPosition) {
return mChilds[groupPosition].length;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return mChilds[groupPosition][childPosition];
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null) {
v = mLayoutInflater.inflate(R.layout.sample_activity_list_child_item, null);
}
final TextView text = (TextView) v.findViewById(R.id.sample_activity_list_child_item_text);
text.setText(mChilds[groupPosition][childPosition]);
return v;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
@Override
public void onClick(View v) {
Toast.makeText(mContext, "ImageView is clicked", Toast.LENGTH_LONG).show();
}
}
Now the issue: if I click on an Image of an "ordinary" groupHeader all things works right and you can see the Toast message. But if I click on an actual "floating" GroupHeader Image this Group expanded/disexpanded.
Thanks for your attention
Hi @diegocarloslima,
Thanks for sharing this. I'm facing the following issue while implementing my custom child view xml .
My implementation is, Assuming i had 10 set of groups each group contains 5 child element. In my child view i have a button a textview when i click button the count will be increased ie (1,2,3....) this will be displayed in the textview.
My problem is i clicked the button which is in Group 1's first child ie (G1 - C0) but it also reflects in all groups first child. How can i solve this. please reply back asap. Thanks in advance
Hi, me again :-)
if you collapse the first floating GroupView and change the orientation of your device, there is no possibility to expand this group again.
Nice new year!
When I touched and begin to scroll, it just crashed.
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.createFloatingGroupView(FloatingGroupExpandableListView.java:416)
Hi,
When the header of the list is stuck, this one become unclickable. I mean not collapsible or expandable.
Let me know if you want more explanations if you can't reproduce this issue.
Thanks.
Hello,
I have registered a context menu on the listview.
//Activity
listView = (FloatingGroupExpandableListView) view.findViewById(android.R.id.list);
registerForContextMenu(listView);
Long press of the Frist Group-Item or Floating-Group-Items don't call the onCreateContextMenu.
Have you a idea to solve the problem?
Hi Diego,
At the moment group view may have different heights based on the state: pinned or not.
Imagine that we have group views with fixed height of 100dp (I've added a grey background to visualize group view bounds):
http://i.imgur.com/C2xEige.png - looks fine.
However, when the group view becomes pinned it will look like that:
http://i.imgur.com/ewyK4aB.png - as you can see group view height was changed!
Steps to reproduce
android:layout_height="wrap_content"
to android:layout_height="100dp"
.v = mLayoutInflater.inflate(R.layout.sample_activity_list_group_item, null);
v = mLayoutInflater.inflate(R.layout.sample_activity_list_group_item, parent, false);
Reason
the real reason is how you inflate the group view at step 3.
When we call mLayoutInflater.inflate without parent param inflater will ignores original layout params of the group layout (so we loose 100dp height). And seems the same you do when pin the group view, so it ignores initial view size and measure it as min height + paddings. Which is not fine. Group view should looks the same pinned and unpinned.
You may want to read a good explanation of the proper layout inflater usage at:
http://www.doubleencore.com/2013/05/layout-inflation-as-intended/
Thanks
Would be great to be able to access this lib via a maven repo!
This library is fantastic, but there is one issue that is keeping me from using it. For some reason, if I navigate away from a fragment that uses a FloatingGroupExpandableListView
, I get an IllegalStateException
because the library tries to call unregisterDataSetObserver
, despite my not using an observer, and never having registered the view. Stack trace is below:
06-09 19:23:47.308 1919-1919/com.example.android.myapp.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.android.myapp.app, PID: 1919
java.lang.IllegalStateException: Observer com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView$6@52a1d58c was not registered.
at android.database.Observable.unregisterObserver(Observable.java:69)
at android.widget.BaseExpandableListAdapter.unregisterDataSetObserver(BaseExpandableListAdapter.java:42)
at com.diegocarloslima.fgelv.lib.WrapperExpandableListAdapter.unregisterDataSetObserver(WrapperExpandableListAdapter.java:29)
at com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView.onDetachedFromWindow(FloatingGroupExpandableListView.java:195)
at android.view.View.dispatchDetachedFromWindow(View.java:12620)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2587)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2585)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3845)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3818)
at android.view.ViewGroup.removeView(ViewGroup.java:3750)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:983)
at android.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1167)
at android.app.BackStackRecord.run(BackStackRecord.java:641)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Scrolling is smooth when small number of groups & childs are present, but when Groups are large with large number of childs then the scrolling is not smooth...
Please reply..
How can I animate items on expanding/collapsing ?
I want to remove up/down arrow on the parent list item icon. these arrows look very light gray color on top of icon how can I remove this. Please help out ASAP.
Thanks!!!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.