[英]How to show progress bar/circle in android
I want to display a progress bar/wheel, when doing some process, for instance, on a button click I want the screen to freeze and show a progress wheel , till the pressed action for example saving data in database is completed. 我想显示一个进度条/滚轮,例如,在执行某些过程时,单击一个按钮,我希望屏幕冻结并显示一个进度轮,直到完成将数据保存到数据库等被按下的操作为止。
Is it possible, please provide code if applicable. 是否可以,请提供代码(如果适用)。
In your OnClick(), I think you must use something like this : 我认为您必须在OnClick()中使用以下方法:
progressDialog = ProgressDialog.show(MyActivity.this,
"title","loading..." , true);
final Runnable runInUIThread = new Runnable() {
public void run() {
//do some work
}
};
new Thread() {
@Override
public void run() {
handler.post(runInUIThread);
progressDialog.dismiss();
}
}.start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.