[英]Open a SlidingDrawer via button
How can I open a SlidingDrawer using a button not attached to it? 如何使用未连接的按钮打开SlidingDrawer? In other words, I like to open it w/o the handle.
换句话说,我喜欢用手柄打开它。
在SlidingDrawer
上调用open()
。
Calling .open()
and .close()
makes the drawer appear and disappear without animation. 调用
.open()
和.close()
会使抽屉出现并消失,而不会生成动画。 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. 我不知道通常是这种情况 - 我在4.03中使用
RelativeLayout
的抽屉进行了测试,它只是在没有动画的情况下弹出视图。
To make the SlidingDrawer
open and close by sliding into the View when clicking a button, use: 要在单击按钮时滑入 View中以打开和关闭
SlidingDrawer
,请使用:
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 slider = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
Call the method "open()", using our object name: 使用我们的对象名称调用方法“open()”:
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();
}
});
您需要覆盖手柄的触摸方法并将触摸事件传递给按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.