본문 바로가기

Android/Android

webView

Permission 추가

 

 

 

activity_main.xml

<WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

 

 

MainActivity.java

public class MainActivity extends Activity {
 private WebView wv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        wv=(WebView)findViewById(R.id.webView1);
        wv.loadUrl("http://smilekimna.tistory.com");
        wv.setWebViewClient(new WebViewClient(){
         public boolean shouldOverrideUrlLoding(WebView view, String url){
          view.loadUrl(url);
          return true;
         }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
     if((keyCode==KeyEvent.KEYCODE_BACK)&&wv.canGoBack()){
      wv.goBack();
      return true;
     }
      //  getMenuInflater().inflate(R.menu.activity_main, menu);
        return super.onKeyDown(keyCode, event);
    }
}

 

 

 

 

'Android > Android' 카테고리의 다른 글

[펌]  (0) 2011.01.20
[펌] XML문서 파싱 3가지  (0) 2010.12.27
안드로이드 특강  (0) 2010.12.02