1.
Buat
Project baru dengan nama webkit.
2.
Pada
layout main_activity desain layout seperti berikut:
3.
Tuliskan
source code pada ActivityMain.java:
package com.example.webkit;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends
Activity {
WebView
browser;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
browser =(WebView)
findViewById(R.id.webkit);
browser.loadData("<html><body>Tulisan
Pertama yang ditampilkan di web
browser</body><html>","text/html","UTF-8");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to
the action bar if it is present.
getMenuInflater().inflate(R.menu.main,
menu);
return true;
}
}
4.
Output:
0 komentar:
Post a Comment
Note: only a member of this blog may post a comment.