웹뷰 활용 : http://croute.me/405
Activity
Layout XML
Activity Code & Layout XML Code |
Activity
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
| package me.croute.webview; import me.croute.R; import android.app.Activity; import android.os.Bundle; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; /** * 웹뷰 사용 기본 예제 * * @author croute * @since 2011.07.27 * @url http://croute.me/458 */ public class WebViewExampleActivity extends Activity { private ProgressBar mPbProgress; private WebView mWvBrowser; /* (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.web_view_example_activity); mPbProgress = (ProgressBar)findViewById(R.id.web_view_example_activity_pb_progress); mWvBrowser = (WebView)findViewById(R.id.web_view_example_activity_wv_browser); mWvBrowser.getSettings().setJavaScriptEnabled( true ); mWvBrowser.setWebViewClient( new WebViewClient()); mWvBrowser.loadUrl(DEFAULT_URL); // 웹뷰의 진행 상태를 표시하기 위한 프로그레스바 mWvBrowser.setWebChromeClient( new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { if (progress< 100 ) { mPbProgress.setVisibility(ProgressBar.VISIBLE); } else if (progress== 100 ) { mPbProgress.setVisibility(ProgressBar.GONE); } mPbProgress.setProgress(progress); } }); } } |
Layout XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <? xml version = "1.0" encoding = "utf-8" ?> android:layout_width = "fill_parent" android:layout_height = "fill_parent" android:orientation = "vertical" android:background = "#FFFFFF" > < ProgressBar android:id = "@+id/web_view_example_activity_pb_progress" android:layout_width = "fill_parent" android:layout_height = "5dp" style = "?android:attr/progressBarStyleHorizontal" /> < WebView android:id = "@+id/web_view_example_activity_wv_browser" android:layout_width = "fill_parent" android:layout_height = "fill_parent" /> </ LinearLayout > |
'개발도구 > aOS - 안드로이드 개발' 카테고리의 다른 글
[안드로이드] GoogleAnalytics 구글분석기 (0) | 2012.02.22 |
---|---|
[안드로이드] 기기 구분, 기기 종류 알아내기 (0) | 2012.02.20 |
[안드로이드] bitmap 을 drawable 로 변환하는 방법 Drawable (0) | 2012.02.17 |
[안드로이드] URL을 이용 imageview 사용하기 Bitmap (0) | 2012.02.17 |
[안드로이드] null 값 비교 (0) | 2012.02.17 |