0

I'm trying to use the SlideExpandableListView library (link) for Android and I've a problem to manage the button that expand the listview... In the source code there is an abstract class (AbstractSlideExpandableListAdapter.java) with a listener, but I don't know how I can implements in my code...

I've tryied this code but doesn't works:

AbstractSlideExpandableListAdapter manageclick = new SlideExpandableListAdapter(adapter);
        manageclick .setItemExpandCollapseListener(new AbstractSlideExpandableListAdapter.OnItemExpandCollapseListener() {
            @Override
            public void onExpand(View itemView, int position) {
                Toast.makeText(getActivity(),"I'm here", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onCollapse(View itemView, int position) {

            }
        });

Can you help me? Thanks!!

user3449772
  • 749
  • 1
  • 14
  • 27
  • I can't understand well the problem, you only need an ListView, your adapter, wrap the adapter with the class SlideExpandableListAdapter, and set your adapter to the ListView. – Gabriel Apr 22 '14 at 19:11
  • Yes, I have an adapter etc... but I need to manage the onExpand event! :) I know that is implemented on library but I don't know how can I call this event. Thanks! – user3449772 Apr 22 '14 at 19:14
  • I remember using this library in a project, but don't remember how to implement such functionality. I think you can implement a listener on the View that is performing the action of expanding in the adapter. If you need to perform an action in the Activity when a row is expanded, you can add an interface on your adapter as if it were Fragments and implement the same methods in the Activity to work as callbacks.[link](http://www.aprendiendodeandroidymas.com/2013/08/como-customizamos-nuestras-vistas-con.html) – Gabriel Apr 22 '14 at 20:02
  • 3 months ago, was added a listener to manage this event. The listener is written in AbstractSlideExpandableListAdapter.java but I don't understand how can I add in my code... :) – user3449772 Apr 22 '14 at 20:07
  • 1
    And if you add a OnItemClickListener to your ActionSlideExpandableListView, and that you handle the View? Anyway, as @MaxLebold says, I would handle it from the adapter. [Adapters](http://www.aprendiendodeandroidymas.com/2013/08/como-customizamos-nuestras-vistas-con.html) – Gabriel Apr 22 '14 at 20:17
  • 1
    I posted an answer here: http://stackoverflow.com/questions/8780292/slide-down-effect-on-expandablelistview/25647564#25647564 Hoep it helps! – Paul Sep 03 '14 at 15:01

1 Answers1

0

Why do you like to react on the buttom-click?

For a ExpandbleListview you dont need to expand or callapse the groups by yourself.

Or is there any other intention?

Maximus1809
  • 575
  • 1
  • 10
  • 30
  • Thanks for reply! :) I needed to drastically change the look of the list view item when it was expanded... – user3449772 Apr 22 '14 at 19:58
  • 1
    I do that on the adapter – Gabriel Apr 22 '14 at 20:04
  • 1
    Me too. This is the perfect place for it. In the adapter. You have there this method: getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) -> here you can act like you want if "isExpanded" is true or false. :) – Maximus1809 Apr 22 '14 at 20:12
  • Mmm, interesting! Sorry for insisting, but I ask you a last question: Can you write a little sample code to see your solution, please? Thanks to all! You're awesome! – user3449772 Apr 22 '14 at 20:23
  • 1
    You can see this [Expandablelistview with custom adapter](http://www.javacodegeeks.com/2013/06/android-expandablelistview-with-custom-adapter-baseexpandablelistadapter.html) I wrote about it, but in Spanish, anyway at the end of the post there are several very useful links in English about Adapters [Adapters](http://www.aprendiendodeandroidymas.com/2013/08/como-customizamos-nuestras-vistas-con.html) – Gabriel Apr 22 '14 at 20:31