如何在显示 ProgressDialog 的 n 秒(固定)延迟后显示 ProgressDialog 按钮?
更清楚地说,ProgressDialog 正常启动。如何在 n 秒后在其中显示一个按钮?
如果
编辑
使用 Segi 和 android_beginner 的答案(非常感谢)我发布了我的问题的解决方案:
pDialog = new ProgressDialog(mContext);
pDialog.setTitle(Reso.getString(mContext, R.string.waiting));
pDialog.setMessage(Reso.getString(mContext, R.string.waiting));
pDialog.setIndeterminate(true);
pDialog.setCancelable(false);
pDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
Reso.getString(mContext, R.string.annulla),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Stuff
}
});
pDialog.show();
pDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(View.INVISIBLE);
int progressDialogCancelButtonDelay = 2500;
new CountDownTimer(progressDialogCancelButtonDelay, progressDialogCancelButtonDelay + 1) {
@Override public void onTick(long millisUntilFinished) { }
@Override public void onFinish() {
pDialog.getButton(ProgressDialog.BUTTON_NEGATIVE).setVisibility(View.VISIBLE);
}
}.start();