Android-SlideExpandableListView icon indicating copy to clipboard operation
Android-SlideExpandableListView copied to clipboard

expandable_toggle_button override OnClickListener

Open ghost opened this issue 12 years ago • 9 comments

I want to do something when the expandable_toggle_button is clicked, how can I override its OnClickListener?

ghost avatar Jun 22 '13 23:06 ghost

I'm interested to do that too and I have found no way. An answer will be very appreciated :)

alepage avatar Jul 06 '13 10:07 alepage

Well, I didn't find anyway except passing my Activity object in the constructor and calling a method in my Activity in the method private void enableFor(final View button, final View target,final int position) in the AbstractSlideExpandableListAdapter where you can find a clicklistener for the button in this method.

ghost avatar Jul 06 '13 11:07 ghost

you can perform that by extending button class:

public class ToggleExpandableMenuButton extends ImageButton {

    private ToggleListener listener;

    public ToggleExpandableMenuButton(Context context) {
        super(context);
    }

    public ToggleExpandableMenuButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ToggleExpandableMenuButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean performClick() {
        if (listener != null) {
            listener.toggle();
        }
        return super.performClick();
    }

    public void setToggleListener(ToggleListener listener) {
        this.listener = listener;
    }

    public static interface ToggleListener {
        public void toggle();
    }
}

ofdrykkja avatar Jul 08 '13 07:07 ofdrykkja

I tried using SlideExpandableListAdapter.setItemExpandCollapseListener(...) passing a new ItemExpandCollapseListener. But it did not work.

The listener is coming as null in the SlideExpandableListAdapter.notifiyExpandCollapseListener() even though I had set it as above.

This is how I am setting the adapter in the list view listView.setAdapter(new SlideExpandableListAdapter(adapter, R.id.expand_toggle_button, R.id.expandable));

Any ideas @tjerkw , why the listener is coming as null? Is it because the setAdapter is wrapping the adapter again?

supareek avatar Mar 08 '14 19:03 supareek

I've tried this code but doesn't works;

new AbstractSlideExpandableListAdapter.OnItemExpandCollapseListener() { @Override public void onExpand(View itemView, int position) { // Code } @Override public void onCollapse(View itemView, int position) { //Code } };

Are there solutions to fix the issue?

Thanks!

robertotucci avatar Apr 22 '14 13:04 robertotucci

also this issue....

timonchev avatar Jan 06 '15 18:01 timonchev

also this issue....

chenchongyu avatar Jul 03 '15 03:07 chenchongyu

also this issue....

xsjqqq123 avatar Nov 12 '15 05:11 xsjqqq123

also this issue....

hadidez avatar Sep 07 '16 23:09 hadidez