开发者

Handle back button in scrollableView

My app is all enclosed inside a ScrollView. When the user clicks the Android back button, I'd like to go back to the previews page of the scrollable view, instead of closing the app. The app should close only when the user clicks the back button whi开发者_运维问答le on page 0. Is this possible, and how?


I found the answer: Use the android:back event AND set the main window as "modal: true"

var win = Titanium.UI.createWindow({  
  modal: true,
  exitOnClose:true
});

win.addEventListener('android:back', function (e) {
  // do what you want here
});


@danmaz74 Your code didn't work for me as expected, instead this worked OK

var secondWindow = Titanium.UI.createWindow({  
  modal: true
});
secondWindow.addEventListener('android:back', function (e) {
   secondWindow.close();
});

And since you want the app to exit on the first window.

var firstWindow = Titanium.UI.createWindow({  
     exitOnClose : true
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜