PhoneGap(特别是Android的DroidGap)有没有告诉其webview已加载的方法。 我想找到类似于以下内容的PhoneGap文档:
正常的WebView客户端创建:
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
}
});
创建我的PhoneGap Webview如下所示:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity);
if (isOnline() == true) {
WebSettings settings = mWebView.getSettings();
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);
settings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://myurl.com");
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
//hide loading image
findViewById(R.id.imageLoading1).setVisibility(View.GONE);
//show webview
findViewById(R.id.mWebView).setVisibility(View.VISIBLE);
}
});
}
else {
//hide loading image
findViewById(R.id.imageLoading1).setVisibility(View.GONE);
//show webview
findViewById(R.id.mWebView).setVisibility(View.VISIBLE);
Intent myIntent = new Intent(getContext(), LoadScreen.class);
startActivity(myIntent);
finish();
}
我的Main_Activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView android:id="@+id/imageLoading1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="visible"
android:src="@drawable/splash"
/>
<WebView android:id="@+id/mWebView"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="gone"
/>
</RelativeLayout>