gpt4 book ai didi

android - 进度对话框微调器不旋转

转载 作者:行者123 更新时间:2023-11-29 16:05:38 24 4
gpt4 key购买 nike

我正在我的应用程序中创建一个进度对话框。下面是我的代码...

ProgressDialog dialog = ProgressDialog.show(TabViewLayout.this, "", "Logout...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.isIndeterminate();
new Thread() {
public void run() {
try {
sleep(5000);
}
catch (Exception e) { }
}
}.start();

Handler handler = new Handler();
handler.post(new Runnable(){
public void run(){
dialog.dismiss();
}
});

我必须做的是,我必须在我的应用程序中为某些进程延迟 5 秒。使用上面的代码,进度对话框出现在屏幕上,但微调器没有旋转。我想让它在旋转模式下运行 5 秒钟。需要做什么?

最佳答案

使用此代码,它将为您工作

ProgressDialog progressDialog;
Context mContext;
private Thread mThread;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mContext = this;
progressDialog = new ProgressDialog(mContext);
progressDialog.setCancelable(false);
progressDialog.setMessage("Loading....");
progressDialog.show();

mThread = new Thread() {
@Override
public void run() {
try {
synchronized (this) {
// Wait given period of time or exit on touch
wait(5000);

}
} catch (InterruptedException ex) {
}

// finish();
progressDialog.dismiss();

}
};
mThread.start();
}

关于android - 进度对话框微调器不旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18786169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com