后退按钮使用 appcelerator 钛退出 android 中的应用程序

问题描述:

我是 Titanium Development 的新手.在原生 android 中,如果我们按下后退按钮,则只会关闭当前活动,它将返回到上一个活动,但是当我使用 Titanium 在 Android 中按下后退按钮时,它会退出应用程序.

I am new to Titanium Development. In Native android if we press back button only current activity will be closed and it will go back to the previous activity but when I press the back button in Android using Titanium it exits from the application.

我该如何改变这种行为?

How can I change this behaviour?

有两种类型的窗口,例如,轻量级和重量级.如果您在 Titanium android 中创建一个轻量级窗口而不是按后退按钮,它将存在于您的应用程序中.

There are two types of windows like, lightweight and heavyweight. If you create a lightweight window in Titanium android than on back button press it will exist from your application.

您可以通过创建重量级窗口来实现您想要的.您可以通过将其作为模式窗口打开来在钛中创建重量级窗口.所以在新建窗口的时候把参数modal:true新窗口将创建为模态窗口(钛 android 的重量级窗口).然后,如果您按下后退按钮,它将不会退出应用程序.

You can achieve what you want by creating heavyweight window. You can create heavyweight window in titanium by open it as modal window. So put the parameter modal:true when you create a new window. New window will be created as modal window (heavyweight window for titanium android). And then after if you will press back button it will not exit from application.