package com.khmc;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class KhmcActivity extends Activity {
 final Activity activity = this;
 ProgressDialog mProgress;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);       <------------이부분이 Link all references for a local rename (does not change references in other files)

WebView infoWebView = (WebView)findViewById(R.id.button1);        

     // 내꺼 webview 사용 명시
     infoWebView.setWebViewClient(new InfoWebViewClient());
    
     // 자바 스크립스 사용
     infoWebView.getSettings().setJavaScriptEnabled(true);
    
     // Load URL
     infoWebView.loadUrl("http://m.khmc.or.kr");
    
    }
    public class InfoWebViewClient extends WebViewClient {
  /**
   * url 주소에 해당하는 웹페이지를 로딩
   */
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
   view.loadUrl("url);
   
   // 안드로이드 자체 WebView가 아닌 내가 만든 WebView 직접 사용한다고 명시
   return true;
  }
  
  /**
   * 웹페이지 로딩이 시작할 때 처리
   */
  @Override
  public void onPageStarted(WebView view, String url, Bitmap favicon) {
   if (mProgress == null) {
    mProgress = new ProgressDialog(activity);
       mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
       mProgress.setTitle("Loading...");
       mProgress.setMessage("Please wait for few second...");
       mProgress.setCancelable(false);
       mProgress.setButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
         mProgress.dismiss();
     }
       });
    mProgress.show();
   }
  }
   
  /**
   * 웹페이지 로딩중 에러가 발생했을때 처리
   */
  @Override
  public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
   Toast.makeText(activity, "Loading Error" + description, Toast.LENGTH_SHORT).show();
    
   if (mProgress.isShowing()) {
    mProgress.dismiss();
   }
  }
   
  /**
   * 웹페이지 로딩이 끝났을 때 처리
   */
  @Override
  public void onPageFinished(WebView view, String url) {
   if (mProgress.isShowing()) {
   mProgress.dismiss();
   }
  }
}
}

 

 

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

 

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.khmc;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
    }
    public static final class id {
        public static final int button1=0x7f050000;
    }
    public static final class layout {
        public static final int webview=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}

 

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

webview.xml

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >
 <WebView
  android:id="@+id/button1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  />
</LinearLayout>