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>