asychtaskを使用して実行時にtextview値と画像ビューをロードしていますが、時間がかかり、progressDialogを画面全体に表示したくありません。代わりに、テキストビューと画像ビューの代わりに小さなプログレスバーが必要です。どうすれば同じことを達成できますか。出来ますか??いくつかのアプリで私は同じを見てきました。
ありがとう
asychtaskを使用して実行時にtextview値と画像ビューをロードしていますが、時間がかかり、progressDialogを画面全体に表示したくありません。代わりに、テキストビューと画像ビューの代わりに小さなプログレスバーが必要です。どうすれば同じことを達成できますか。出来ますか??いくつかのアプリで私は同じを見てきました。
ありがとう
Dialog
はい、クラスを拡張するカスタムダイアログを使用できます
import android.app.Dialog;
import android.content.Context;
import android.widget.ProgressBar;
import android.widget.RelativeLayout.LayoutParams;
public class MyProgressDialog extends Dialog {
public static MyProgressDialog show(Context context, CharSequence title,
CharSequence message) {
return show(context, title, message, false);
}
public static MyProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate) {
return show(context, title, message, indeterminate, false, null);
}
public static MyProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate, boolean cancelable) {
return show(context, title, message, indeterminate, cancelable, null);
}
public static MyProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate,
boolean cancelable, OnCancelListener cancelListener) {
MyProgressDialog dialog = new MyProgressDialog(context);
dialog.setTitle(title);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
/* The next line will add the ProgressBar to the dialog. */
dialog.addContentView(new ProgressBar(context), new LayoutParams(40,40));
dialog.show();
return dialog;
}
public MyProgressDialog(Context context) {
super(context, R.style.NewDialog);
}
}
アクティビティでは、次のように呼び出して次のように表示します。
MyProgressDialog dialog=MyProgressDialog.show(this, null,null);
いつものように却下しdialog.dismiss()
ます。style.xmlで属性を指定できます
これがあなたにできることです。ProgressBarはレイアウトのビューとして追加できるので、これを画像ビューとテキストビューの上にビューとして追加するだけで(たとえばFrameLayoutを使用)、データを取得したら、またはの可視性ProgressView
を設定できます。INVISIBLE
GONE
のjavadocページには、ProgressBar
使用できるコードサンプルもあります。