개발 창고/Android

[Kotlin] Confirm 창을 사용하는 방법

로이제로 2023. 7. 26. 22:00
반응형
// import androidx.appcompat.app.AlertDialog

val builder = AlertDialog.Builder(this)
builder.setTitle("확인 타이틀")      // Confirm 제목
builder.setMessage("확인 메시지")    // Confirm 내용
builder.setPositiveButton("확인") { dialog, which ->
    // 긍정 (확인 / 저장 등등) 팝업의 하단 맨 우측에 표기 됨
}
builder.setNegativeButton("취소") { dialog, which ->
    // 부정 (취소 / 닫기 등등) 기본적으로 Positive Button 좌측에 표시 됨 
}
builder.show()                    // 선언된 Confirm을 띄워줌

Confirm 팝업은 자주 사용하지만 거의 비슷하게 사용되다 보니 기록용으로 남겨둡니다.

Confirm Alert Dialog

setTitle : Confirm의 제목으로 설정하지 않으면 그 영역만큼 표시 되지 않습니다.

setMessage : Confirm의 주요 내용이 보여집니다.

setPositiveButton : 긍정 버튼으로 주로 Confirm에서 처리하려는 Action이 맞는 경우 표시합니다. (하단 우측)

setNegativeButton : 부정 버튼으로 주로 Confirm에서 처리하려는 Action을 하지 않는 경우 표기합니다. (PositiveButton 좌측)

setNeutralButton : 그외 일반 버튼으로 Confirm의 하단 좌측에 표기되며, PositiveButton/NavigativeButton과 사용방법은 동일합니다.

 

※ 이 글은 워드프레스에 작성한 글과 동일한 작성자의 동일한 글입니다.

https://royfactory.net/2023/07/03/kotlin-confirm-alert-dialog/

 

[Kotlin] How to use the Confirm window - ROY FACTORY

How to make Confirm windows on Kotlin on Android? In this article, we test with the available sources immediately.

royfactory.net

 

반응형