xifan2008
xifan2008
  • 发布:2015-02-28 09:23
  • 更新:2015-02-28 09:23
  • 阅读:1799

android backbutton 不起作用呢

分类:MUI

调用代码如下

function selfplusReady() {
//首頁返回鍵處理
//處理邏輯:1秒內,連續兩次按返回鍵,則退出應用;
var first2 = null;
plus.key.addEventListener('backbutton', function() {
//首次按鍵,提示‘再按一次退出應用’
if (!first2) {
first2 = new Date().getTime();
mui.toast('再按一次退出應用');
setTimeout(function() {
first2 = null;
}, 1000);
} else {
if (new Date().getTime() - first2 < 1000) {
plus.runtime.quit();
}
}
}, false);
}

程序里面采用了webview模式

var subpages = ['news.html', 'add.html', 'cal.html', 'ask.html', 'acount.html', 'login.html', 'signup.html','newsall.html','speed.html'];
var subpage_style = {
top: '45px',
bottom: '50px'
};

var self_view=null;
mui.plusReady(function() {
self_view = plus.webview.currentWebview();
for (var i = 0; i < 9; i++) {

                    var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);  
                    if (i > 0) {  
                        sub.hide();  
                    }  

                    self_view.append(sub); //只有有这个代码就后退按钮不生效  

            }  
        });
2015-02-28 09:23 1 条评论 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复