코틀린(Kotlin)공부
BottomSheetDialog_Modal - Kotlin
스텝바이스텝안드로이드
2021. 3. 29. 15:55
1. bottomSheetDialog xml 파일을 만든다.
2. bottomSheetFragment를 아래와 같이 만든다.
class BottomSheetFragmentCustomer : BottomSheetDialogFragment() {
private val mContext: Context? = context
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.custom_bottomsheet_addcus, container, false)
val manualCreateBtn: MaterialButton = view.findViewById(R.id.manuallyAdd)
val fromBookBtn: MaterialButton = view.findViewById(R.id.fromPhonebook)
manualCreateBtn.setOnClickListener(View.OnClickListener {
val intent = Intent(context, CreateCustomerActivity::class.java)
startActivity(intent)
dismiss()
})
fromBookBtn.setOnClickListener(View.OnClickListener {
val intent = Intent(context, CreateCustomerActivity::class.java)
startActivity(intent)
dismiss()
})
return view
}
}
3. activity에서 호출한다.
val frag = BottomSheetFragmentEvent()
frag.show(supportFragmentManager, frag.tag)