Android的警告对话框 - 如何隐藏确定按钮它是pressed后 [英] Android Alert Dialog - how to hide the OK button after it being pressed
本文介绍了Android的警告对话框 - 如何隐藏确定按钮它是pressed后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在开发一个Android应用程序。
我想隐藏确定按钮,用户presses后,为对话窗口会留在前台几秒钟而计算的发生。
这是在code:
新AlertDialog.Builder(本)
.setMessage(这可能需要一段时间)
.setPositiveButton(OK,新android.content.DialogInterface.OnClickListener(){
@覆盖
公共无效的onClick(DialogInterface对话,诠释它){
//隐藏确定按钮 - 怎么样?
//大量的运算
}
})
。显示();
我怎样才能做到这一点?
PS:我不是有趣的更先进的技术来处理计算(如:进程对话,多线程)。
感谢。
解决方案
.setPositiveButton(OK,新android.content.DialogInterface.OnClickListener(){
@覆盖
公共无效的onClick(DialogInterface对话,诠释它){
((AlertDialog)对话框).getButton(所).setVisibility(View.INVISIBLE);
//你的东西休息
}
})
I have been developing an Android app.
I would like to hide the OK button after the user presses it, as the dialog window will stay at the foreground for some seconds while a computation takes place.
This is the code:
new AlertDialog.Builder(this)
.setMessage("This may take a while")
.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// hide the OK button - how?
// a lot of computation
}
})
.show();
How can I achieve that?
P.S.: I am not interesting to more advanced techniques to handle a computation (such as: progress dialogs, multi-threading).
Thanks.
解决方案
.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((AlertDialog)dialog).getButton(which).setVisibility(View.INVISIBLE);
// the rest of your stuff
}
})
这篇关于Android的警告对话框 - 如何隐藏确定按钮它是pressed后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文