I'm a little embarrassed to post this, but I can't figure out where I am going wrong. I looked at each example and each and everything looks right for me. That's what I'm doing. I have a list that, when you click on an item, takes you to a WebView that displays some static formatted text associated with this list.
Everything worked for me with TextView, but I wanted to be able to use HTML formatting of the text and computing WebView was the way to go. It is currently assumed to display a general link for testing, but when the viewContent intent begins, it just goes to the black screen. I can go back and select another entry, and also just shows a black screen.
I'm not sure which code you want to see, so the viewSection class file and the viewsection.xml layout.
viewSection.java:
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class viewSection extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView wv;
setContentView(R.layout.viewsection);
wv = (WebView) findViewById(R.id.wv1);
wv.loadData("<a href='x'>Hello World! - 1</a>",
"text/html",
"utf-8");
}
}
viewsection.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<WebView android:id="@+id/wv1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
source
share