How to detect event tap on specific image

animation

#1

var gestures = require(“ui/gestures”);

for (var i = 0; i < images.length; i++) {
imgArray[i] = new imageModule.Image();
imgArray[i].id = “img”;
imgArray[i].width = w / 6;
imgArray[i].height = h / 7;
imgArray[i].src = images[i];
imgArray[i].stretch = “fill”;
wrap_layout.addChild(imgArray[i]);
imgArray[i].on(gestures.GestureTypes.tap, function (args) {
console.log(“tap”+"|"+i);
});

this my loop adding array of images to WrapLayout on nativescript is work well my problem is I’m trying to implement tap gesture for each image is work but doesn’t specific index of Image any idea how solve it


#2

Set imgArray[i].id = i; // instead of setting same id to every image
Try console logging args.object.id to get the index


#3

thanks man you save me thanks so much


#4

i add imgArray[i].name = i ; and i log args.object.name and is worl without touch the id


#7

its work without getview by id