WebView 로딩중 에만 ProgressBar 진행상태 표시
페이지 정보
작성자 MintState 댓글 0건 조회 15,452회 작성일 11-05-16 10:58본문
WebView 로딩중 에만 ProgressBar 진행상태 표시
웹페이지 로딩시 프로그레스바를 보이고 로딩이 끝나면 사라지게하는 방법
Layout
Class
참고
http://blog.outsider.ne.kr/464
http://developer.android.com/reference/android/webkit/WebView.html
출처 : http://blog.naver.com/free2824/60123140115
웹페이지 로딩시 프로그레스바를 보이고 로딩이 끝나면 사라지게하는 방법
Layout
01 | <FrameLayout |
02 | android:layout_width="fill_parent" |
03 | android:layout_height="wrap_content" |
04 | android:layout_weight="1"> |
05 | <WebView android:id="@+id/webView" |
06 | android:layout_width="fill_parent" |
07 | android:layout_height="fill_parent" /> |
08 | <ProgressBar android:id="@+id/progress_horizontal" |
09 | style="?android:attr/progressBarStyleHorizontal" |
10 | android:layout_width="fill_parent" |
11 | android:layout_height="5dp" |
12 | android:max="100" |
13 | android:visibility="gone" /> |
14 | </FrameLayout> |
Class
01 | ProgressBar mProgressHorizontal = (ProgressBar) findViewById(R.id.progress_horizontal); |
02 | WebView mWebView = (WebView)this.findViewById(R.id.webView); |
03 | mWebView.getSettings().setJavaScriptEnabled(true); |
04 |
05 | mWebView.setWebViewClient(new MyWebViewClient(){ |
06 | @Override |
07 | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
08 | view.loadUrl(url); |
09 | return true; |
10 | } |
11 |
12 | @Override |
13 | public void onPageStarted(WebView view, String url, Bitmap favicon) { |
14 | super.onPageStarted(view, url, favicon); |
15 | mProgressHorizontal.setVisibility(View.VISIBLE); |
16 | } |
17 |
18 | @Override |
19 | public void onPageFinished(WebView view, String url) { |
20 | super.onPageFinished(view, url); |
21 | mProgressHorizontal.setVisibility(View.INVISIBLE ); |
22 | } |
23 |
24 | @Override |
25 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { |
26 | super.onReceivedError(view, errorCode, description, failingUrl); |
27 | Toast.makeText(Flipper_Activity.this, "로딩오류" + description, Toast.LENGTH_SHORT ); |
28 | } |
29 | }); |
30 |
31 |
32 | mWebView.setWebChromeClient(new WebChromeClient(){ |
33 | @Override |
34 | public void onProgressChanged(WebView view, int newProgress) { |
35 | mProgressHorizontal.setProgress(newProgress); |
36 | } |
37 | }); |
참고
http://blog.outsider.ne.kr/464
http://developer.android.com/reference/android/webkit/WebView.html
출처 : http://blog.naver.com/free2824/60123140115
|
|
댓글목록
등록된 댓글이 없습니다.





WebView 로딩중 에만 ProgressBar 진행상태 표시