Android: Do Events (Swipe) Work with Views?
Hello,
On the iPhone KitchenSink app, on the Base UI –> Views screen there is an item called "Events with Views." When I tap that item, I see a screen that records events such as touchstart
, singletap
, swipe
etc.
On the Android KitchenSink app, there is no "Events with Views" item under Base UI –> Views.
I want to use a swipe gesture to scroll between views that are displaying an image along with a couple of buttons. On the Android emulator, when I do a click/hold + mouse move to simulate a swipe, the image moves right or left but no swipe
event appears to fire (I have a Ti.API.info
in the swipe
event handler).
My question: Is the swipe
event supported on Android views? If not, is there another way I can swipe to move between images on the view?
Judging from how the "Events with Views" demo is absent from Android KitchenSink, and from my own experience, I'm guessing events aren't working on Android views, but I want to make sure.
Thank you!!!!
-Ryan
4 Answers
-
Accepted Answer
The 'swipe' event for Android was just merged in the titanium_mobile master. It should be available in the continuous integration builds shortly. If you don't feel like waiting, you could always go out to github and clone titanium_mobile.
Details on the issue can be found in this ticket: TIMOB-767
-
Not sure if this is still relevant but this is how I implemented swipe on Android:
var x_start; my_image_view.addEventListener('touchstart', function (e) { x_start = e.x; }); my_image_view.addEventListener('touchend', function (e) { if (e.x > x_start) { swipe({direction: 'right'}); } else { swipe({direction: 'left'}); } }); // And then my swipe function: function swipe(e) { if (e.direction == 'left') { //... } else { //... } }
-
Hi Ryan,
In Android, 'swipe' event did not work for View, it only worked for "ScrollView". Even Iam trying to get that swipe effect on View, currently Iam working on it but I am tyring to use "touchstart" and "touchmove" events to achieve this.I can share that code with you once I get it functional.
-ajay -
Ryan
This feature is not yet available for android, except for scrollView. Tickets #767, #768, and #1703 are the ones to watch if you want to be kept up to date by email.