android - 钛合金背压事件

标签 android appcelerator appcelerator-alloy

我正在尝试使用appcelerator 处理钛合金中android 的后按事件。但是当用户按下回车键时,应用程序将在 Android 中关闭。谁能告诉我解决办法吗?

exitOnClose= false ;

 $.index.addEventListener('androidback', function(e){
    // write your code here
    Ti.API.info('android back pressed');
    return;
});

我已按照建议添加了此代码,但它不起作用。

最佳答案

捕获事件而不执行任何操作

Ti.UI.currentWindow.addEventListener('androidback',function(event){
      event.cancelBubble = true;
      return false;
}

还可以使用 exitOnClose 属性:http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Window-property-exitOnClose

关于android - 钛合金背压事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36788534/

相关文章:

android TabItem onClick 不起作用

钛 JS : cannot use an image stored in SQLite Database in TiSocial module

javascript - Appcelerator - Javascript - 丢失引用

ios - Appcelerator 第三方框架 arm64 错误

ios - 从 xml appcelerator ios 创建动态行数

Appcelerator 应用程序转换 iOS 到 Android。

node.js - 如何在appcelerator Alloy中安装和使用NPM包

java - android在异步任务中更新自定义 View

java - 如何将 getDuration 放入 TextView 中?

android - 如何在 JetpackCompose String 中访问复数资源