본문 바로가기

IT 연구회

webview

반응형

package com.example.jake;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ViewFlipper;

public class Main extends Activity {

private WebView webview;

Button start, stop;
ViewFlipper flipper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

webview = (WebView) findViewById(R.id.webview);

webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setLightTouchEnabled(true);
webview.getSettings().setSavePassword(true);
webview.getSettings().setSaveFormData(true);

webview.setWebViewClient(new MyWebViewClient());

webview.loadUrl("http://i-detox.blog.me");
}

private class MyWebViewClient extends WebViewClient {

public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}

}

 

 

 

 

 

 

 

 

 

 

 

<LinearLayout 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"
android:orientation="vertical" >

<webView

android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</LinearLayout>

반응형