tjerkw / Android-SlideExpandableListView

A better ExpandableListView, with animated expandable views for each list item
Apache License 2.0
1.98k stars 741 forks source link

Added suport for animation’s listener with an example #89

Closed VictorAlbertos closed 9 years ago

VictorAlbertos commented 9 years ago

Hi!

I use this library frequently and I think it’s really useful. But something I’ve missed so far it’s a group of callbacks to listening for when a row is expanding or collapsing (starting or ending). For that reason, I’ve added a simple interface to handle it:

public interface SlideExpandableListener { public void onStartExpandAnimation(View view, int position); public void onEndExpandAnimation(View view, int position); public void onStartCollapseAnimation(View view, int position); public void onEndCollapseAnimation(View view, int position); }

This interface could be implemented and linked to an instance of SlideExpandableListAdapter as follow:

slideAdapter.setExpandableSlideListener(new SlideExpandableListener() {

        @Override
        public void onStartExpandAnimation(View view, int position) {
            Log.d("slide", "start animation expand with item position: " + position);
        }

        @Override
        public void onEndExpandAnimation(View view, int position) {
            Log.d("slide", "end animation expand with item position:" + position);
        }

        @Override
        public void onStartCollapseAnimation(View view, int position) {
            Log.d("slide", "start animation collapse with item position: " + position);
        }

        @Override
        public void onEndCollapseAnimation(View view, int position) {
            Log.d("slide", "end animation collapse with item position: " + position);
        }

});

Also, I’ve faced a few problems trying to compile the project with the current version of Android Studio (0.8.14). So I've had to make some changes to get it to work.

Greetings, Victor.

tjerkw commented 9 years ago

There is no need for this listener, since the expansion is always triggered by a click on the Toggle button, which you can listen for.