YesYo.com MintState Forums
뒤로    Go3.co.kr MintState BBS > Tech > Android
검색
멤버이름    오토
비밀번호 
 

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

페이지 정보

작성자 MintState 댓글 0건 조회 15,452회 작성일 11-05-16 10:58

본문

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

웹페이지 로딩시 프로그레스바를 보이고 로딩이 끝나면 사라지게하는 방법



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
01ProgressBar mProgressHorizontal = (ProgressBar) findViewById(R.id.progress_horizontal);
02WebView mWebView = (WebView)this.findViewById(R.id.webView);
03mWebView.getSettings().setJavaScriptEnabled(true);
04 
05mWebView.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 
32mWebView.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
첨부 파일
파일 종류: png device.png (33.9K, 72 views)

댓글목록

등록된 댓글이 없습니다.

Total 18건 1 페이지
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2025, Go3.co.kr MintState. ™