通过钛合金按钮退出应用程序

sur*_*dra 2 titanium titanium-mobile

当我试图通过点击按钮退出应用程序时,我对钛非常新,它再次显示钛闪屏!

我使用以下代码

var win=Ti.UI.createWindow({
    backgroundColor:'#ddd',
    exitOnClose:true        
});

var button=Ti.UI.createButton({
    title:'back',
    left:10,top:10  
});

button.addEventListener('click',function(e){
    win.close();
});

var text=Ti.UI.createLabel({
    text:'Home page',
    color:'#000',
    font:{ fontSize:20} 
});

win.add(button);
win.add(text);

win.open();
Run Code Online (Sandbox Code Playgroud)

如何通过按钮单击退出应用程序?

Ana*_*and 8

您可以通过将以下属性添加到应用程序的第一个窗口来关闭应用程序.

     exitOnClose: true
Run Code Online (Sandbox Code Playgroud)

然后在关闭窗口的位置键入以下代码

     win.close();
     var activity = Titanium.Android.currentActivity;
     activity.finish();
Run Code Online (Sandbox Code Playgroud)

参考:退出Titanium Application Android.希望它能解决你的问题!!