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?
You should take a look at the method
setOnDrawerOpenListener.Create your own
OnDrawerOpenListenerand use it to check if the data is null – if it is, close the drawer again:You would need a reference to your
SlidingDrawerand you would needOnDrawerOpenedto be an inner class, so you can access the reference to yourSlidingDrawer.Alternative
You could also create your own subclass by extending
SlidingDrawerand 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
SlidingDrawerin your XML:Depeding on how and when you get the data to check for null, you might want to either pass it to
MySlidingDrawerin its constructor or add a method through which you can set the data.