jQuery加载微调器没有显示

时间:2014-06-03 09:33:41

标签: javascript android jquery loading

我正在开发android应用程序,我正在尝试显示加载微调器,而我的html正在格式化,但微调器没有显示,我不明白为什么。
这是代码:

$.mobile.loading('show');
    if (window.localStorage.getItem("UserTeams") != null && manual == false) {
        $(window.localStorage.getItem("UserTeams")).appendTo("#listTeams");
        $("#listTeams").listview("refresh").listview();           
    }
$.mobile.loading('hide');

为什么旋转器没有显示的任何想法?

1 个答案:

答案 0 :(得分:1)

尝试通过JavaSriptInterface使用本机函数来显示进度。

JavaScriptInterface:

private final class JavaScriptInterface {

    public JavaScriptInterface() {
    }

    /* progressDialog is a field of Your Activity.
       JavaScriptInterface is internal class of Your Activity. */

    public void showDialog() {
        if (progressDialog != null) {
            if (!progressDialog.isShowing()) {
                progressDialog = ProgressDialog.show(this, "", getString(R.string.common_loading_upper));
            }
        }
    }

    public void hideDialog() {
        if (progressDialog != null) {
            progressDialog.dismiss();
        }  
    }
}

注册JavaScriptInterface:

webView.addJavascriptInterface(new JavaScriptInterface(), "myinterface");

调用对话框的JavaScript代码:

window.myinterface.showDialog();