public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView wv = (WebView) findViewById(R.id.webView1);
final String mimeType = "text/html";
final String encoding = "utf-8";
final String html = "<h1>Header</h1>" +
"<p>Custom HTML</p>" +
"<p> <img height=42 width=42 src = file:///android_asset/ic_launcher.png></img></p>";
wv.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, "");
}
}
And the XML file is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/textView1"
android:layout_alignLeft="@+id/button1"
/>
</RelativeLayout>
No comments:
Post a Comment