简体   繁体   English

jQuery $ .ChangePage回调Android

[英]Jquery $.ChangePage callback Android

I have a website which is displayed in a Android Webview App. 我有一个显示在Android Webview应用程序中的网站。

I use JqueryMobile (1.10.2) and the ChangePage method in order to navigate through my website. 我使用JqueryMobile(1.10.2)和ChangePage方法来浏览我的网站。 Pages ask a webservice so they can take time to be displayed. 页面要求Web服务,因此它们可能需要一些时间才能显示。

I want to display a Toast (Android) during the page is loading. 我要在页面加载期间显示Toast(Android)。 It works, but I don't know how to know when my page is loaded 它有效,但是我不知道如何加载页面

My question is: It is possible to know when the page is loaded by the $.ChangePage method in order to hide my Android Toast ? 我的问题是:可以知道何时通过$ .ChangePage方法加载页面以隐藏我的Android Toast?

Here my code: 这是我的代码:

$('div.ui-page').swipeleft(function (e) {
    //$("#pop").popup("open");
    window.Android.showToast();
    $.mobile.changePage("mypage", {
        transition: "slide"
    });
})

Into my Android App (with @JavascriptInterface): 进入我的Android应用程序(使用@JavascriptInterface):

@JavascriptInterface
public void hideToast() {
    if(wait > 0) {
        wait--;
    }
    if(wait == 0) {
        montoast.cancel();
    }
}    

public void showToast() {
    wait++;
    montoast.setText("loading...");
    montoast.show();
}
jQuery( ".selector" ).on( "pagechange", function( event ) { ... } )

This event is triggered after the changePage() request has finished loading the page into the DOM and all page transition animations have completed 在changePage()请求完成将页面加载到DOM中并且所有页面转换动画都完成之后,触发此事件

Explanation Of the Event 事件说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM