替代SET按钮 [英] Alternative setButton
本文介绍了替代SET按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Android项目使用code:
alertDialog.setButton(OK,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释它){
}
});
不过,Eclipse的说, SET按钮()
是德precated。请帮我一个替代的解决方案。谢谢!
解决方案
AlertDialog.Builder建设者=新AlertDialog.Builder(活动);
builder.setTitle(ALERTTILESTRING)
.setMessage(alertNameString)
.setCancelable(假)
.setNegativeButton(关闭,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话框,INT ID){
dialog.cancel();
}
});
AlertDialog警报= builder.create();
alert.show();
}
我希望以上code是一个很好的在对话框中工作得非常好
I use this code in my android project:
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
But, Eclipse says that setButton()
is deprecated. Please, help me with an alternative solution. Thanks!
解决方案
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("ALERTTILESTRING")
.setMessage("alertNameString")
.setCancelable(false)
.setNegativeButton("Close",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
I hope the above code is a good one in which dialog works very well
这篇关于替代SET按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文