sencha touch中处理Android返回按钮事件
16lz
2021-01-23
应用中只有一个NavigationView的情况:
在Ext.tab.Panel下有多个NavigationView的情况:
// 处理一下android返回按钮document.addEventListener("deviceready", onDeviceReady, false);function onDeviceReady() {document.addEventListener("backbutton", onBackKeyDown, false);}function onBackKeyDown() {var canPop = false;var id = Ext.Viewport.getActiveItem().id;if (id.indexOf("login") != -1) {} else if (id.indexOf("mainview") != -1) {var mainview = Ext.Viewport.getActiveItem();var length = mainview.getItems().length;if (length > 2) {canPop = true;}}if (canPop) {console.log("canPop");ChinaFertilizer.app.getController("MainController").pop(1);} else {Ext.Msg.confirm("提示", "您确定要退出应用吗?", function(e) {if (e == "yes") {navigator.app.exitApp();}}, this);}}
在Ext.tab.Panel下有多个NavigationView的情况:
// 处理一下android返回按钮document.addEventListener("deviceready", onDeviceReady, false);function onDeviceReady() {document.addEventListener("backbutton", onBackKeyDown, false);}function onBackKeyDown() {var item = Ext.Viewport.getActiveItem();var id = item.id;if (id.indexOf("mainView") != -1) { var mainview = Ext.Viewport.getActiveItem();// var mainview = Ext.getCmp('moreView').getActiveItem(); var length = mainview.getActiveItem().getItems().length; console.log("length = " + length); if(length > 2){ if(app.viewId == 0){ app.getController("phone.MyAppControllerP").pop(1); }else if(app.viewId == 1){ app.getController("phone.TodoControllerP").pop(1); }else if(app.viewId == 2){ app.getController("phone.AppCenterControllerP").pop(1); }else if(app.viewId ==3){ app.getController("phone.MoreControllerP").pop(1); } }else{ if (typeof WL === 'undefined') { Ext.Msg.confirm("提示", "您确定要退出应用吗?", function(e) { if (e == "yes") { navigator.app.exitApp(); } }, this); } else { WL.SimpleDialog.show("提示", "您确定要退出应用吗?", [ { text : "确定", handler : function() { navigator.app.exitApp(); } }, { text : "取消", handler : function() { } } ]); } } }else{ if (typeof WL === 'undefined') { Ext.Msg.confirm("提示", "您确定要退出应用吗?", function(e) { if (e == "yes") { navigator.app.exitApp(); } }, this); } else { WL.SimpleDialog.show("提示", "您确定要退出应用吗?", [ { text : "确定", handler : function() { navigator.app.exitApp(); } }, { text : "取消", handler : function() { } } ]); } }
更多相关文章
- android如何查看app的内存占用情况
- 给Android的音量按钮添加监听事件
- 拷贝的Android源码不能单独编译mmm命令提示找不到
- Android在配置文件中配置Button再不同情况下的的背景
- 多个按钮左右相互挤压效果
- Android Material Design按钮样式设计
- Android 中英文切换(点击按钮切换语言)
- android logcat鼠标悬浮提示过快