单击滑动抽屉处理程序时执行操作
在我的应用程序中,我只想在数据不为空时填充滑动绘制。 因此,当用户按下滑动抽屉处理程序时,它应该给出一个对话框“数据为空”,并且滑动抽屉不应打开。
我已经尝试过 Handler.setOnTouchListener() 但发生的情况是在任何调用触摸事件且出现对话框的地方。
有什么建议吗?
In my application I want to fill the sliding draw only when data is not null.
So , when the user presses on the sliding drawer handler it should give a dialog "Data is empty" and sliding drawer should not open.
I have tried Handler.setOnTouchListener() but what happens is anywhere a touch event is called that dialog box appear.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该看一下方法
setOnDrawerOpenListener
。创建您自己的
OnDrawerOpenListener
并使用它检查数据是否为空 - 如果是,则再次关闭抽屉:您需要对
SlidingDrawer
的引用,并且需要OnDrawerOpened
是一个内部类,因此您可以访问对SlidingDrawer
的引用。替代
您还可以通过扩展
SlidingDrawer
创建自己的子类,然后重写animateOpen()
和open()
方法(您可能也需要重写animateToggle()
和toggle()
):如果您这样做,您将需要引用您自己的实现XML 中的
SlidingDrawer
:根据获取数据以检查 null 的方式和时间,您可能需要将其传递给其构造函数中的
MySlidingDrawer
或通过添加一个方法您可以设置数据。You should take a look at the method
setOnDrawerOpenListener
.Create your own
OnDrawerOpenListener
and use it to check if the data is null - if it is, close the drawer again:You would need a reference to your
SlidingDrawer
and you would needOnDrawerOpened
to be an inner class, so you can access the reference to yourSlidingDrawer
.Alternative
You could also create your own subclass by extending
SlidingDrawer
and then override theanimateOpen()
andopen()
methods (you might need to overrideanimateToggle()
andtoggle()
too):If you do this, you would need to reference your own implementation of the
SlidingDrawer
in your XML:Depeding on how and when you get the data to check for null, you might want to either pass it to
MySlidingDrawer
in its constructor or add a method through which you can set the data.