[英]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.