How can I open a Slidi开发者_开发技巧ngDrawer using a button not attached to it? In other words, I like to open it w/o the handle.
Call open()
on the SlidingDrawer
.
Calling .open()
and .close()
makes the drawer appear and disappear without animation. I don't know if this is generally the case - I tested this on 4.03 with the drawer in a RelativeLayout
and it just popped into view without animation.
To make the SlidingDrawer
open and close by sliding into the View when clicking a button, use:
slidingDrawer.animateOpen();
and
slidingDrawer.animateClose();
Im not sure if you still need help or not but I was just wondering the same thing.
"SlidingDrawer" is our object called "slider":
SlidingDrawer slider = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
Call the method "open()", using our object name:
slider.open();
Example button that just opens the sliding drawer:
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
slider.open();
}
});
You need to override the handle's touch method(s) and pass down the touch event to the button.
精彩评论