I'm looking for a recommendation on the best way to create a back button that would work on both IOS and Android. Would it be to simply create a Ti.UI.createButton() that links to the previous back?
1 Answer
here is an example of how to create the android back button using the Native back button.
Titanium.UI.setBackgroundColor('white'); var window1 = Ti.UI.createWindow({ backgroundColor:"red", navBarHidden:false, title:"Main Window" }); window1.addEventListener('click', function(){ var window2 = Ti.UI.createWindow({ backgroundColor:"green", navBarHidden:false, title:"Sub Window" }); window2.addEventListener('android:back', function(e) { Ti.API.info("Log: The Android back button was pressed - DO SOMETHING!!!!"); // when overriding the back button, the default behavior // (in most cases, close) needs to be explicitly coded window2.close(); }); window2.open(); }); window1.open();you would basically add that event and either the name of the window to close or
Ti.UI.currentWindow.close();
Your Answer
Think you can help? Login to answer this question!