Webview Black screen, please help!

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Webview Black screen, please help!

Postby TRDanny » Tue Jul 21, 2009 4:57 pm

Hi, when I run this, I get a black screen

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView wv = (WebView) findViewById(R.id.wv1);
try {
InputStream is = getAssets().open("file.htm");

int size = is.available();

// Read the entire asset into a local byte buffer.
byte[] buffer = new byte[size];
is.read(buffer);
is.close();

// Convert the buffer into a Java string.
String text = new String(buffer);

// Load the local file into the webview
wv.loadData(text, "text/html", "UTF-8");

} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}

or:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView wv = (WebView) findViewById(R.id.wv1);
try {
InputStream is = getAssets().open("file.htm");

int size = is.available();

// Read the entire asset into a local byte buffer.
byte[] buffer = new byte[size];
is.read(buffer);
is.close();

// Convert the buffer into a Java string.
String text = new String(buffer);

// Load the local file into the webview
wv.loadUrl("file:///assets/file.htm");


} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}

or

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.google.com");

}

Please help!

P.S. I think the first two does the same thing?
TRDanny
Freshman
Freshman
 
Posts: 7
Joined: Mon Jul 13, 2009 3:07 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests