Hi , I am working with android 2.3.3. i have two button in my app such as right left for changing picture. But in android 2.2 it did work and i could get the next image by clicking on the right button an previous image by clicking on the left button. But in 2.3.3 this button are shown but whn clicking on them nothing happen. So please someone give me a sloution
the code is like this "
var left = Titanium.UI.createButton({ backgroundImage: 'images/icon_arrow_left.png', top:380, left:20 }); //If the left button is clicked then show the previous photo left.addEventListener('click', function(e) { if (selectedPhotoIndex > 0) { //Decrease the photo index and current photo number selectedPhotoIndex--; var currenPhotoNumber = selectedPhotoIndex + 1; //Change the window title win.title = currenPhotoNumber + ' of ' + photosArray.length; //Change the image imageView.image = "http://farm" + photosArray[selectedPhotoIndex].farm + ".staticflickr.com/" + photosArray[selectedPhotoIndex].server + "/" + photosArray[selectedPhotoIndex].id + "_" + photosArray[selectedPhotoIndex].secret + "_m.jpg"; if(Ti.Platform.osname==='ios'){ actIndicator.show(); } //Change the photo title labelTitle.text = photosArray[selectedPhotoIndex].title; //Change the username if (photosArray[selectedPhotoIndex].userData) labelUploadedBy.text = "Uploaded By: " + photosArray[selectedPhotoIndex].userData.username; else loadUserInfo(selectedPhotoIndex); } }); var right = Titanium.UI.createButton({ backgroundImage: 'images/icon_arrow_right.png', top:380, right:20 }); //If the right button is clicked then show the next photo right.addEventListener('click', function(e) { if (selectedPhotoIndex < photosArray.length - 1) { //Increase the photo index and current photo number selectedPhotoIndex++; var currenPhotoNumber = selectedPhotoIndex + 1; //Change the window title win.title = currenPhotoNumber + ' of ' + photosArray.length; //Change the image imageView.image = "http://farm" + photosArray[selectedPhotoIndex].farm + ".staticflickr.com/" + photosArray[selectedPhotoIndex].server + "/" + photosArray[selectedPhotoIndex].id + "_" + photosArray[selectedPhotoIndex].secret + "_m.jpg"; if(Ti.Platform.osname==='ios'){ actIndicator.show(); }
2 Answers
Well, all the code being executed is dependent of the following condition:
if (selectedPhotoIndex > 0) {Are you sure absolutely sure that this variable is higher than zero?
Some logs could help you determine that, like so:
if (selectedPhotoIndex > 0) { Ti.API.debug('left button has been clicked'); ... }If you see the logs, but nothing happens, then you know thee is something with your execution logic. If you don't see the logs, then it's related to the eventListener.
One more thing, try to be as concise as possible when posting code samples. Having all the code contained in your event listeners don't bring much to the table and make it harder to read for everyone. Thus making it more difficult for everyone to understand.
Finally got a solution i think. I was testing the application in google api 2.3.3 and the screen was HVGA in emulator. But when I changed the screen to QVGA or other screen except HVGA the button did work. So I think this was a emulator problem. Please let me know if I am wrong or right.
Your Answer
Think you can help? Login to answer this question!