Notice
Recent Posts
Recent Comments
반응형
오늘도 공부
소스 #3 - Dialog 없이 wheel 만 있는 ProgressBar 만들고 WebView 위에서 사용하기 본문
Android/Tip&Tech
소스 #3 - Dialog 없이 wheel 만 있는 ProgressBar 만들고 WebView 위에서 사용하기
행복한 수지아빠 2011. 4. 15. 21:05반응형
출처 : http://www.androidpub.com/748389
질답에 세번 질문을 하면서..동시에 구글링과 야후 검색을 며칠동안 한 결과..
Dialog 를 상속 받아서 customizing 해야 한다는 결론을 얻었습니다.
외국의 어느 커뮤니티에 누군가 남긴 상속 받아 재정의한 코드를 얻었구요.
가져올 때 링크를 기록하지 않았더니...다시 찾아보려고 노력해도...
찾을 수가 없네요.
여기에 감사의 글과 함께..링크를 올리고 싶었지만...다시 못찾은 관계로...패스~
감사의 마음만...가득합니다.
우선.. 상속 받은 코드는 질답게시판에 댓글로도 올렸지만.
정리하는 차원에서 여기 다시 올립니다.
아래는 Dialog 를 상속 받은 클래스입니다.
위의 코드에서 참조하는 NewDialog 의 스타일은 다음과 같습니다. res/values/styles.xml 을 생성 시키고
아래의 코드를 넣습니다.
Dialog 를 이용하기 때문에.. 그리고.. WebView 에서 PageFinished 이벤트가 있기 때문에,
쓰레드를 사용할 필요가 없다는 것을 알게 되었습니다.
질답에 세번 질문을 하면서..동시에 구글링과 야후 검색을 며칠동안 한 결과..
Dialog 를 상속 받아서 customizing 해야 한다는 결론을 얻었습니다.
외국의 어느 커뮤니티에 누군가 남긴 상속 받아 재정의한 코드를 얻었구요.
가져올 때 링크를 기록하지 않았더니...다시 찾아보려고 노력해도...
찾을 수가 없네요.
여기에 감사의 글과 함께..링크를 올리고 싶었지만...다시 못찾은 관계로...패스~
감사의 마음만...가득합니다.
우선.. 상속 받은 코드는 질답게시판에 댓글로도 올렸지만.
정리하는 차원에서 여기 다시 올립니다.
아래는 Dialog 를 상속 받은 클래스입니다.
01.class MyProgressDialog extends Dialog {02. 03. 04.public static MyProgressDialog show(Context context, CharSequence title,05.CharSequence message) {06.return show(context, title, message, false);07.}08. 09.public static MyProgressDialog show(Context context, CharSequence title,10.CharSequence message, boolean indeterminate) {11.return show(context, title, message, indeterminate, false, null);12.}13. 14.public static MyProgressDialog show(Context context, CharSequence title,15.CharSequence message, boolean indeterminate, boolean cancelable) {16.return show(context, title, message, indeterminate, cancelable, null);17.}18. 19. 20.public static MyProgressDialog show(Context context, CharSequence title,21.CharSequence message, boolean indeterminate,22.boolean cancelable, OnCancelListener cancelListener) {23.MyProgressDialog dialog = new MyProgressDialog(context);24.dialog.setTitle(title);25.dialog.setCancelable(cancelable);26.dialog.setOnCancelListener(cancelListener);27./* The next line will add the ProgressBar to the dialog. */28.dialog.addContentView(new ProgressBar(context), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));29.dialog.show();30. 31.return dialog;32.}33. 34.public MyProgressDialog(Context context) {35.super(context, R.style.NewDialog);36.}37.}위의 코드에서 참조하는 NewDialog 의 스타일은 다음과 같습니다. res/values/styles.xml 을 생성 시키고
아래의 코드를 넣습니다.
01.<resources>02.<style name="NewDialog">03.<item name="android:windowFrame">@null</item>04.<item name="android:windowBackground">@android:color/transparent</item>05.<item name="android:windowIsFloating">true</item>06.<item name="android:windowContentOverlay">@null</item>07.<item name="android:windowTitleStyle">@null</item>08.<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>09.<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>10.<item name="android:backgroundDimEnabled">false</item>11.<item name="android:background">@android:color/transparent</item>12.</style>13. 14.</resources>Dialog 를 이용하기 때문에.. 그리고.. WebView 에서 PageFinished 이벤트가 있기 때문에,
쓰레드를 사용할 필요가 없다는 것을 알게 되었습니다.
1.package pkg.WebViewTest;01.import android.app.Activity;02.import android.app.Dialog;03.import android.content.Context;04.import android.os.Bundle;05.import android.os.Handler;06.import android.os.Message;07.import android.util.Log;08.import android.view.MotionEvent;09.import android.view.View;10.import android.view.ViewGroup.LayoutParams;11.import android.webkit.WebView;12.import android.webkit.WebViewClient;13.import android.widget.Button;14.import android.widget.ProgressBar;15.import android.widget.TextView;1.public class WebViewTest extends Activity {2./** Called when the activity is first created. */3. 4.public MyProgressDialog progressDialog;1.@Override2.public void onCreate(Bundle savedInstanceState) {3.super.onCreate(savedInstanceState);4. 5.setContentView(R.layout.main);6.wvc = (WebView)findViewById(R.id.WebView01);7.wvc.getSettings().setJavaScriptEnabled(true);01.wvc.loadUrl("http://m.naver.com"); 02.progressDialog = MyProgressDialog.show(this,"","",true,true,null);03. 04.wvc.setWebViewClient(new WebViewClient()05.{06.@Override07.public void onPageFinished(WebView view, String url)08.{09.wvc.setVisibility(View.VISIBLE);10.if (progressDialog!=null)11.progressDialog.dismiss();12.}13.});14.}1.}
반응형
'Android > Tip&Tech' 카테고리의 다른 글
| android 내장메모리에 쓰기 (0) | 2011.04.22 |
|---|---|
| 마켓 등록 정보 (0) | 2011.04.20 |
| Android Gallery 2D , 3D effect (0) | 2011.04.15 |
| [펌]프로그레스바 투명하게 만들기.(첨부파일 있음) (0) | 2011.04.14 |
| Android Button drawable 속성정보 [출처] Android Button drawable 속성정보 |작성자 아즈라엘 (0) | 2011.04.14 |
