我有一个信息弹出窗口,其中有2个按钮:Negative(取消)和Positive(Continue)。如何在单击后禁用正按钮。 单击按钮生成一个文件。它调用的函数非常繁重,因此关闭弹出窗口需要时间。我这样做是为了防止用户点击两次,从而生成两个文件。
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.close_tour_tour_not_collected);
builder.setItems(items, null);
builder.setPositiveButton(R.string.common_continue, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0,
int arg1) {
// How to disable the button after the click???
saveTourAndCloseActivity();
}
});
非常感谢你的帮助! :)
答案 0 :(得分:1)
(Dialog.class.cast(arg0)).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
答案 1 :(得分:0)