[英]How to set color or highlight PositiveButton and NegativeButton in alert dialog box and customized
[英]how to set alert dialog box open until status change
我有一个警告对话框,显示不存在Internet连接时的情况。 我删除了“确定”按钮,以便用户无法将其关闭。 但是,如果互联网的状态已变为打开状态,如何关闭它呢?
这是我的警报对话框中的代码:
public void showAlertDialog(Context context, String title, String message, Boolean status) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
// Setting Dialog Message
alertDialog.setMessage(message);
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
// Showing Alert Message
alertDialog.show();
}
这是我的称呼:
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
switch (v.getId()) {
case R.id.btn_login:
new AttemptLogin().execute();
default:
break;
}
} else {
// Internet connection is not present
// Ask user to connect to Internet
showAlertDialog(Login.this, "No Internet Connection",
"You don't have internet connection.", false);
}
尝试使用可监听ConnectivityManager.CONNECTIVITY_ACTION
的BroadcastReciver
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.