Android 进度对话框代替文本视图、图像视图
我正在使用asychtask在运行时加载textview值和图像视图,这需要时间,我不想在整个屏幕上显示progressDialog。相反,我想要一个小进度条来代替文本视图和图像视图。我怎样才能达到同样的效果。有可能吗?? 在一些应用程序中,我也看到了同样的情况Android 进度对话框代替文本视图、图像视图,android,progressdialog,Android,Progressdialog,我正在使用asychtask在运行时加载textview值和图像视图,这需要时间,我不想在整个屏幕上显示progressDialog。相反,我想要一个小进度条来代替文本视图和图像视图。我怎样才能达到同样的效果。有可能吗?? 在一些应用程序中,我也看到了同样的情况 谢谢是的,您可以使用扩展对话框类的自定义对话框 import android.app.Dialog; import android.content.Context; import android.widget.ProgressBar;
谢谢是的,您可以使用扩展
对话框
类的自定义对话框
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);
照常关闭对话框。关闭()
。您可以在style.xml中指定属性,这就是您可以做的。可以作为视图添加到布局中,因此只需将此作为视图添加到图像视图和文本视图的顶部(使用say),一旦有了数据,就可以将ProgressView
的可见性设置为不可见或消失
ProgressBar
的javadoc页面也有您可以使用的代码示例。是的,这是可能的。参考这些链接:,,我想你还没有理解我,兄弟。我只想在TextView(小)的位置显示进度对话框,因为它是在惰性图像加载的情况下显示的Bro我喜欢它,。这东西没问题。。但是我不想在整页都显示它。我只想为单个textview和imageview显示它,直到它从asynchtask加载。现在了解了,然后在您想要显示的地方使用xml it self中的Prograss栏。然后你可以玩“可见”和“消失”