Android Kotlin 커스텀 다이얼로그 만들기
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="male"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="female"/>
</RadioGroup>
</LinearLayout>
package com.example.mysungjinlee
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import com.example.mysungjinlee.databinding.ActivityMainBinding
import com.example.mysungjinlee.databinding.DialogInputBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
val dialogBinding = DialogInputBinding.inflate(layoutInflater)
AlertDialog.Builder(this).run {
setTitle("당신의 성별은 무엇 입니까?")
setView(dialogBinding.root)
setPositiveButton("닫기" , null)
show()
}
}
}