次のURLで webview を読み込む際に問題があります。
しかし、どちらも webview で空のページを表示しています。
ここにソースコードを添付しました。どうすればこの問題から抜け出すことができますか?
ソース:
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
public class WEBVIEW_ITSELF extends Activity {
WebView homeWeb;
Button btnPlay;
final Activity activity = this;
static Context mContext;
public boolean orandationChange = true;
@Override
protected void onPause() {
super.onPause();
orandationChange = false;
}
String urlchange;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.i_webview);
mContext = this;
homeWeb = (WebView) findViewById(R.id.website_webview);
homeWeb.getSettings().setJavaScriptEnabled(true);
homeWeb.getSettings().setSupportZoom(true); // Zoom control on web (You)
homeWeb.clearHistory();
homeWeb.clearFormData();
homeWeb.clearCache(true);
WebSettings webSettings = homeWeb.getSettings();
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
homeWeb.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100)
activity.setTitle(R.string.app_name); // To enable this you
// should not set
// android:theme="@android:style/Theme.Black.NoTitleBar"
// in the manifest file.
}
});
homeWeb.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
System.out.println(" failingUrl " + failingUrl);
System.out.println(" description " + description);
System.out.println(" errorCode " + errorCode);
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
homeWeb.loadUrl("http://mobile.walmart.com/");
}
}