Thanks for trying to solve my problem!
My app is currently loading a webpage using an Android webview. The disadvantage is that sometimes (with a bad connection) a web page takes more than 10 seconds to load. Is there a way to create some kind of XML splatter loading screen when loading a web page?
Take a look at my code ...
package com.ect;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class SomeActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CookieSyncManager.createInstance(getBaseContext());
getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
public void onPageFinished(WebView view, String url) {
CookieSyncManager.getInstance().sync();
}
});
CookieSyncManager.getInstance().startSync();
CookieSyncManager.getInstance().sync();
webview.loadUrl("http://www.web.com/");
}
}
This is my code. If you look closely, I made a comment that says: "THIS IS WHAT I WANT: ..."
This comment will cause the main.xml file to be displayed, but if I use this comment, the main.xml file will be displayed, but the webview will never appear ...
How can I display the main.xml file and then (after loading the web view) display the web page?