1.3 Android: OnClick Event not fired on ImageView inside ScrollView
Title says it all. The nesting is as follows:
Win->ScrollView->View->ImageView
OnClick fires fine if the ImageView is only within another view. As soon as the View is inside a ScrollView, the OnClick event is not fired.
I believe this was introduced in 1.3 since it was working fine under 1.2.
Looking at the source, there were definitely made some changes to the onclick handling, but I can't figure out what exactly is wrong.
Any hints on this are appreciated :)
3 Answers
-
Hi,
I'm having the same problem, it works on the iPhone but not on the Andoid.
I tried also to put the listener on the image view, but nothing gets triggered.
Is there a way to solve this?
Thanks -
Hey Barry..
It's possible that the ScrollView's drag logic is overriding our touch listener on the ImageView.. does it work if the ImageView is the only child of the ScrollView? (i.e. Win->ScrollView->ImageView)
-
Thanks for the reply!
I'm not quite sure how to add the imageview to the scrollview. But the click event fires if it's done like so:var scrollView = Titanium.UI.createScrollableView({}); scrollView.add(imageview);
However, this make the scrollview kind of useless..
Here is a full code example. The event is fired on iPhone but not on Android
var win = Titanium.UI.currentWindow; var image = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/image.png'); var imageview = Ti.UI.createImageView({image:image}); imageview.addEventListener('click', function(e) { alert('X'); }); var views = []; views[0] = Ti.UI.createView({ backgroundColor:'#336699' }); views[0].add(imageview); var scrollView = Titanium.UI.createScrollableView({ views: views }); win.add(scrollView);