WebView 로딩중 에만 ProgressBar 진행상태 표시
페이지 정보
작성자 MintState 댓글 0건 조회 15,524회 작성일 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
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> <WebView android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <ProgressBar android:id="@+id/progress_horizontal" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="5dp" android:max="100" android:visibility="gone" /> </FrameLayout>
Class
ProgressBar mProgressHorizontal = (ProgressBar) findViewById(R.id.progress_horizontal);
WebView mWebView = (WebView)this.findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
mProgressHorizontal.setVisibility(View.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mProgressHorizontal.setVisibility(View.INVISIBLE );
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
Toast.makeText(Flipper_Activity.this, "로딩오류" + description, Toast.LENGTH_SHORT );
}
});
mWebView.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
mProgressHorizontal.setProgress(newProgress);
}
});
참고
http://blog.outsider.ne.kr/464
http://developer.android.com/reference/android/webkit/WebView.html
출처 : http://blog.naver.com/free2824/60123140115
|
|
댓글목록
등록된 댓글이 없습니다.





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