Search code examples
androidtitaniumappcelerator

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 while on page 0. Is this possible, and how?


Solution

  • 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
    });