「Android/kotlin/Alert」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
|||
| 22行目: | 22行目: | ||
.show() | .show() | ||
</pre> | </pre> | ||
==枠外クリックでキャンセル防止== | |||
setCancelable(false)を追加 | |||
<pre> | |||
AlertDialog.Builder(this) | |||
.setCancelable(false) | |||
</pre> | |||
参考:http://nishi.sunnyday.jp/Knowledge/Android/tips/AlertDialog/setCancelable | |||
2020年3月31日 (火) 05:41時点における版
okのみ
AlertDialog.Builder(context)
.setTitle("タイトル1")
.setMessage("文章1")
.setPositiveButton("OK") { dialog, which ->
Log.i("AlertDialog", "OK")
}
.show()
ok,cancelの2択
AlertDialog.Builder(context)
.setTitle("タイトル1")
.setMessage("文章1")
.setPositiveButton("OK") { dialog, which ->
Log.i("AlertDialog", "OK")
}
.setNegativeButton("Cancel"){ dialog, which ->
Log.i("AlertDialog", "Cancel")
}
.show()
枠外クリックでキャンセル防止
setCancelable(false)を追加
AlertDialog.Builder(this)
.setCancelable(false)
参考:http://nishi.sunnyday.jp/Knowledge/Android/tips/AlertDialog/setCancelable