결과화면 

// WebViewDemoA3.java

 

package com.example.graphic;

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebViewDemoA4 extends Activity {
 private WebView webview;

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.webview_demo);
  
  webview = (WebView)this.findViewById(R.id.webview);
  webview.getSettings().setJavaScriptEnabled(true);
  webview.setWebViewClient(new MyWebViewClient());
  
  webview.loadUrl("http://fs1025.mireene.com");
 }
 
 public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
 }

 private class MyWebViewClient extends WebViewClient{

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

 

 

 

 

 

// webview_demo.xml

 

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

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

</RelativeLayout>

 

 

 

<!-- 매니페스트에 권한 추가!!! -->

<uses-permission android:name="android.permission.INTERNET" />

 

<!-- 화면 모드가 변경될 때 onConfigurationChanged()메소드가 호출되게 하기 위해서
            추가한다.
            3.2 이전 버전에서는 keyboardHidden|orientation
            3.2 부터는 orientation|scrteenSize 로 지정한다. -->
            
            android:configChanges="orientation|screenSize">

 

--------------------------------------------------------------------------------------------------

 

// assets 폴더에 jsalert.html 넣어주자! 코드는 밑과 다음과 같다....

 

 

<html>
<head>
<title>경고창</title>

<body>
<h2>
<a href="javascript:alert('경고창입니다.');"> 경고창 보기</a>
</h2>
</body>
</html>

+ Recent posts