sencha touch中处理Android返回按钮事件
2016-02-18 17:08
447 查看
应用中只有一个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) { < 4000 span class="indent"> 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() { } } ]); } }
相关文章推荐
- AndroidStudio中Git的使用
- 利用Android的媒体库,遍历SD卡中的音乐文件,并用Service制作简单的音乐播放
- android 软键盘完全解析 InputMethodManager
- 关于Android中android:marginBottom不起作用以及android:signleLine对文字的影响
- 在Fragment如何使用共享元素转场动画
- Android中处理崩溃异常——补充内容
- android 开发 百度地图 最新指定区域截图
- Android之Monkey全参数(包含隐藏参数)
- Android中通过进程注入技术修改系统返回的Mac地址
- 国内优秀Android学习资源
- Android APK反编译得到Java源代码和资源文件
- android悬浮窗口的实现
- android: qq 5.0 demo学习笔记(主 粒子爆炸效果+ViewDragHelper)
- android到底可以加载多大的图不报OOM错误
- Android基础篇(三)——Android中的Activity简单介绍
- Android常用布局样式
- LeakCanary:跟OOM说再见
- AndroidStudio使用笔记
- android中activity的四种启动模式
- Android 中解决ScrollView嵌套ListView或者GridView时的冲突问题