Open ghost opened 11 years ago
I'm interested to do that too and I have found no way. An answer will be very appreciated :)
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.
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();
}
}
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?
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!
also this issue....
also this issue....
also this issue....
also this issue....
I want to do something when the expandable_toggle_button is clicked, how can I override its OnClickListener?