Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- 안드로이드
- mybatis
- 오버로딩
- paint
- 클래스
- Menu
- 메서드
- oracle
- 전화걸기
- Java
- 어노테이션
- JavaScript
- layout
- Android
- 생성자
- HTML
- 에러페이지
- Spring
- AWT
- OGNL
- 기본
- struts2
- Graphic
- 배열
- 국제화
- 예외처리
- 메소드
- Eclips
- JSP
- 이클립스
Archives
- Today
- Total
note
Browser WebView (브라우저) 본문
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
package com.commonsware.android.browser1;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class BrowserDemo1 extends Activity {
WebView browser;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
browser = (WebView)findViewById(R.id.webkit);
browser.loadUrl("http://m.naver.com");
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
package com.commonsware.android.browser2;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class BrowserDemo2 extends Activity {
WebView browser;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
browser = (WebView)findViewById(R.id.webkit);
String msg = "Hello, world! 안녕하세요!";
browser.loadData(msg,"text/html","UTF-8");
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
package com.commonsware.android.browser3;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class BrowserDemo3 extends Activity {
WebView mWeb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWeb = (WebView)findViewById(R.id.web);
mWeb.setWebViewClient(new MyWebClient());
WebSettings set = mWeb.getSettings();
set.setJavaScriptEnabled(true);
set.setBuiltInZoomControls(true);
mWeb.loadUrl("http://m.nate.com");
}
//HTML페이지에서 링크를 클릭할 때 발생하는 이벤트를 처리하는 클래스
class MyWebClient extends WebViewClient{
//전달되는 인자
//WebView view : 실행중인 WebView 객체
//String url : 클릭한 링크(링크를 다시 받아 내부에서 처리)
public boolean shouldOverrideUIrlLoading(WebView view, String url){
view.loadUrl(url);
return true;
}
}
}
2번 빼고 permission 권한 INTERNET을 주어야 한다 이전 게시물 참고
http://javai.tistory.com/363
간단히 말하면 manifest.xml 접근 -> permission 탭 -> add -> uses -> INTERNET -> 저장
(밑으로 내려갈수록 발전되는 기능을 볼수 있음 )
'Android > 기본' 카테고리의 다른 글
| Access Web (0) | 2012.01.12 |
|---|---|
| NetWork Wifi , 3G (0) | 2012.01.12 |
| Handler 사용하기 (로딩 표시?) (0) | 2012.01.11 |
| Activity 생명주기 (0) | 2012.01.11 |
| Message 팝업창 띄우기 경고창,토스트 표시,Progress Dialog (0) | 2012.01.11 |