I am working on a small, but nice open source project: A RealViewSwitcher
that allows to switch between multiple views by performing a horizontal fling - like the Launcher of Android does. It is just a simple ViewGroup
that implements onInterceptTouchEvent
and onTouchEvent
to make things work. In fact most of the code is taken from the file Workspace.java
(line 572 and following), so are the two methods to handle touch events - without many changes.
However, I don't get this thing to work. My current working class is posted here (on pastebin because it is pretty large): http://pastebin.com/8p8GCEZK
If I execute my class (just creating it, adding some TextViews and then setting it as the content view of the activity) I get the following output if I do a quick fling:
12-15 23:53:04.797: INFO/RealViewSwitcher(7477): intercept ACTION_DOWN
12-15 23:53:04.797: INFO/RealViewSwitcher(7477): touch ACTION_DOWN
12-15 23:53:04.807: INFO/RealViewSwitcher(7477): touch ACTION_MOVE
12-15 23:53:04.840: INFO/RealViewSwitcher(7477): touch ACTION_MOVE
12-15 23:53:04.867: INFO/RealViewSwitcher(7477): touch ACTION_MOVE
12-15 23:53:04.897: INFO/RealViewSwitcher(7477): touch ACTION_MOVE
12-15 23:53:04.897: INFO/RealViewSwitcher(7477): touch ACTION_UP
My problem now is: Whatever I do, I don't get the ACTION_MOVE
in my onInterceptTouchEvent
method. I read the documentation multiple times and tried to play with the return values, but I don't get any other events than the ACTION_DOWN
there - which is ugly, because the actual code that starts the fling resides in the ACTION_MOVE
case.
Can you help me out here? The annoying thing which I can not get: It seems to be implemented the same way in the official Launcher application. But their code works, mine doesn't. What am I missing?