Webview shows a blank screen instead of the webpage
i have alt.xml and main.xml, alt.xml has a edittext and a button, main.xml has a webview, whenever i try to load a page with the webview it just loads a blank page. i'll post my code below, thanks in advance.
package com.tyran.webviewer;
import android.app.Activity;
import android.os.Bundle;
import android.text.开发者_开发百科Editable;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
public class WebViewer extends Activity {
WebView browser;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.alt);
}
public void selfDestruct(View view) {
loadTime();
}
void loadTime() {
setContentView(R.layout.main);
browser=(WebView)findViewById(R.id.webview);
browser.setWebViewClient(new Callback());
browser.getSettings().setJavaScriptEnabled(true);
final EditText edittext = (EditText) findViewById(R.id.edittext);
Editable text = edittext.getText();
String Tekst = text.toString();
browser.loadUrl(Tekst);
}
private class Callback extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
loadTime();
return(true);
}
}
{
}}
Please add following line in your activity tag in AndroidManifest.xml
activity
android:hardwareAccelerated="false"
I also had same problem but this help me out.
精彩评论