我尝试在我的应用程序中显示活动指示器。我使用activity.js作为活动指示器。它在浏览器和iPhone上运行良好,但在安卓设备上不起作用。
我不知道为什么指示器在android设备上不能工作。
下面是我的activity indicator示例代码:
function showIndicator() {
console.log("inside show indicator");
applyOverLay();
var showIndicator = document.createElement("div");
showIndicator.setAttribute("class", "activity-indicator");
document.body.appendChild(showIndicator);
$('.activity-indicator').activity({
width: 5,
space: 1,
length: 3,
color: '#fff'
});
}
function applyOverLay() {
var overlay = document.createElement("div");
overlay.setAttribute("id", "overlayAttr");
overlay.setAttribute("class", "overlay");
document.body.appendChild(overlay);
}
function hideindicator() {
$('.activity-indicator').activity(false);
setTimeout(function() { $(".activity-indicator").empty().remove(); }, 0);
setTimeout(function() { $(".overlay").empty().remove(); }, 0);
}
function loadhtmlpage() {
//location.href='#refillReminder';
$.mobile.changePage("#refillReminder");
showIndicator();
hideindicator();
}
style.css:
.activity-indicator {
padding: 10px;
position: absolute;
top: 50%;
left: 45%;
z-index: 1001;
}发布于 2013-04-05 13:05:45
我已经使用以下代码在Android..try this上显示了本机活动指示器。这可能会有帮助..
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$(document).bind("ajaxSend", function() {
navigator.notification.activityStart("App Name","Loading...");
}).bind("ajaxStop", function() {
navigator.notification.activityStop();
}).bind("ajaxError", function() {
navigator.notification.activityStop();
});
}发布于 2013-09-25 04:27:34
也许您应该尝试在jquery 方法中显示指示器,并向#refillReminder 页面中的页面显示方法添加一个处理程序来关闭它。
我使用了ajax移动端的默认指示器,您尝试在jQuery调用之类的长操作之前在同一页中显示,并将其隐藏在always处理程序中。
同样奇怪的是,当你用0超时来显示它之后,你试图隐藏它的正确性。
发布于 2013-10-22 22:45:03
您可以使用默认的jquery移动活动指示器作为后备,使用:
$.mobile.loading('hide'); //to hide the spinner
$.mobile.loading('show'); //to show the spinner该组件非常灵活,您可以使用主题或覆盖旋转的gif。
更多信息请点击此处Jquery Mobile Loader
https://stackoverflow.com/questions/13509877
复制相似问题