Titanium Appcelerator back button closes my window
Asked Answered
A

3

7

I'm working on building my first Android app on Titanium. I have an RSS feed loading on the first window, then after clicking a link from the rss list, I create a new window and display the full content of the rss item on that page.

What I want to achieve is that when I'm on the second window (full content of rss feed) and press the Back button from my phone, I want to return to the first window (rss list). At the moment my app exits when pressing the back button from anywhere from my app.

On the first window, I have specified exitOnClose: true and on the second I have specified exitOnClose: false. Not sure if that's what I need to do.

Any help is much appreciated & thanks in advance.

Maikel

Acrobatics answered 31/8, 2010 at 7:6 Comment(1)
Check out the discussion about this problem here: developer.appcelerator.com/question/2731/…Distal
A
7

I found the answer.

When I open a new window, I just pass modal:true and that fixes it

Acrobatics answered 6/9, 2010 at 2:40 Comment(1)
Another thing that helps is creating the window with fullscreen: falseJohannesburg
K
3

Let try

var btnMap = Ti.UI.createButton ({
    title:'Click here to open map',
    width:300, height:50, top:100
});
win.add(btnMap);
btnMap.addEventListener('click', function(){
    var mapWin = Titanium.UI.createWindow({  
        title:'France Map',
        tabBarHidden:true,
        url:'francemap.js'
    }); 
    Ti.UI.currentTab.open(mapWin);
});

It means you should use Ti.UI.currentTab.open(mapWin) instead of use mapWin.open(). Remember that always use tab to manage your window.

Krystinakrystle answered 4/10, 2010 at 16:6 Comment(1)
Is there any way to add navigation bar in titanium?Bookstore
F
0

If you open a new window with and it has a bar at the top it will have a button to the previous page automatically. You can also put a button into the bar on your own

var back = Ti.UI.createButton({
    title: "Back",
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
back.addEventListener("click", function() {
    Ti.UI.currentWindow.close();
});
Ti.UI.currentWindow.setLeftNavButton(back);
Feel answered 8/2, 2012 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.