问题描述
我用ProgressDialog表明,他要等待,让我的应用贱民,而用户必须等待表面的用户。我添加了一个按钮progressDialog应该启动一些行动,如果某些条件为真。问题是,每次用户preSS的按钮,progressDialog被自动解除。即使没有动作被触发。我怎样才能prevent的progressDialog从得到解雇时的onClick叫?
THX&放大器;关于
编辑:
connectingDialog =新ProgressDialog(本);
connectingDialog.setCancelable(假);
connectingDialog.setCanceledOnTouchOutside(假);
connectingDialog.setButton(DialogInterface.BUTTON_NEUTRAL,开始,新DialogInterface.OnClickListener(){
@覆盖
公共无效的onClick(DialogInterface为arg0,INT ARG1){
/ *如果(是prepared)
开始游戏();*/
connectingDialog.show(); //不行,太
}
});
connectingDialog.show();
设置的ProgressDialog显示 OnClickListener
之后。
与其他一些对话框
S提供的Android, ProgressDialog
不具有 setNeutralButton()
方法,所以你需要设置 onClickListener
的 ProgressDialog
已后,显示,像这样:
connectingDialog =新ProgressDialog(本);
connectingDialog.setCancelable(假);
connectingDialog.setCanceledOnTouchOutside(假);
//创建按钮,但设置监听器空对象。
connectingDialog.setButton(DialogInterface.BUTTON_NEUTRAL,开始,
(DialogInterface.OnClickListener)空)
//显示对话框,所以我们就可以得到该视图按钮。
connectingDialog.show();
//从视图按钮。
按钮dialogButton = connectingDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
//这里设置onClickListener,在视图中。
dialogButton.setOnClickListener(新View.OnClickListener(){
@覆盖
公共无效的onClick(视图查看){
如果(是prepared){
connectingDialog.dismiss();
开始游戏();
}
//对话将不会被解雇,除非是ppared $ P $。
}
});
I' using ProgressDialog to show the user that he has to wait and to make the surface of my app "untouchable" while the user has to wait. I added a Button to the progressDialog which should start some actions if certain conditions are true. The problem is that everytime the user press the button the progressDialog gets automatically dismissed. Even if no action is triggered. How can I prevent the progressDialog from getting dismissed when onClick is called?
thx & regards
EDIT:
connectingDialog = new ProgressDialog(this);
connectingDialog.setCancelable(false);
connectingDialog.setCanceledOnTouchOutside(false);
connectingDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "start", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
/*if(isPrepared)
startGame();*/
connectingDialog.show(); // does not work, too
}
});
connectingDialog.show();
Set the OnClickListener
After the ProgressDialog is Shown.
Unlike some of the other Dialog
s available in Android, ProgressDialog
does not have a setNeutralButton()
method so you need to set the onClickListener
after the ProgressDialog
has been shown, like so:
connectingDialog = new ProgressDialog(this);
connectingDialog.setCancelable(false);
connectingDialog.setCanceledOnTouchOutside(false);
// Create the button but set the listener to a null object.
connectingDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "start",
(DialogInterface.OnClickListener) null )
// Show the dialog so we can then get the button from the view.
connectingDialog.show();
// Get the button from the view.
Button dialogButton = connectingDialog.getButton( DialogInterface.BUTTON_NEUTRAL );
// Set the onClickListener here, in the view.
dialogButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick ( View view ) {
if (isPrepared) {
connectingDialog.dismiss();
startGame();
}
// Dialog will not get dismissed unless "isPrepared".
}
});
这篇关于prevent ProgressDialog从得到驳回的onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!