** Permission (AndroidManifest.xml)
<uses-permission android:name="android.permission.INTERNET" />
** Activity
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
class xxx extends Activity {
WebView webview;
...
webview = (WebView)findViewById(R.id.webView1);
webview.setWebViewClient(new WebClient());
WebSettings setting = webview.getSettings();
setting.setJavaScriptEnabled(true);
setting.setBuiltInZoomControls(true);
webview.loadUrl("http://google.com");
// url page 표시할 때
// html을 표시할 때
// String html = " <font color='red'><b> Output </font>";
// webview.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
...
class WebClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
댓글
댓글 쓰기