์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ
- filternot
- ๋ค์์ ๋ฆฌํ๊ธฐ
- iPortfolio
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ_1์ฃผ์ฐจ
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ_2์ฃผ์ฐจ
- ์ทจ์ค๊ธฐ๋ก
- ๋ค์ ์ ๋ฆฌํด์ผํจ
- recyclerview
- ์ฝํ๋ฆฐ
- array๋ list
- foldindexed
- Filter
- ๋ค์๋ด
- ์ฝ๋ฉํ ์คํธ
Archives
- Today
- Total
Moments of growth
[Kotlin] Dialog setOnClickListener ๋ณธ๋ฌธ
๐ ์๋ชป ๊ตฌํํ ์ฝ๋
binding.btnCreate.setOnClickListener{
val DialogView = LayoutInflater.from(context).inflate(R.layout.fragment_create_dialog,null)
val Builder = AlertDialog.Builder(context)
.setView(DialogView)
Builder.show()
}
โ ์ด๋ ๊ฒ ๊ตฌํํ ๊ฒฝ์ฐ ์๋ก์ด ๋ทฐ๊ฐ ์์ฑ๋ผ์ CreateDialogFragment.kt์์ ์ ์ํ setOnClickListener๋ฅผ ์ฌ์ฉํ ์ ์๋ค
-> ์ด ๋ถ๋ถ ์ ์ดํด๋ชปํจ (๋ ๊ณต๋ถ ํ์)
๐ InHomeFragment.kt (์ฌ๋ฐ๋ฅธ ์ฝ๋)
binding.btnCreate.setOnClickListener{
CreateDialogFragment().show(childFragmentManager,"")
}
โ show()๋ก ๊ตฌํํ๋ฉด ๊ฐ๋ฅํ๋ค
โ CreateDialogFragment.kt ์์ ๊ตฌํํ ํด๋ฆญ๋ฆฌ์ค๋๋ค์ ์ฌ์ฉํ ์ ์๋ค
๐ CreateDialogFragment.kt
class CreateDialogFragment : DialogFragment() {
private var _binding: FragmentCreateDialogBinding? = null
private val binding get() = _binding ?: error("์๋ฌ์๋ฌ")
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentCreateDialogBinding.inflate(
layoutInflater,
container,
false
)
binding.btnCancel.setOnClickListener {
dismiss()
}
binding.btnListen.setOnClickListener {
val intent = Intent(requireContext(), ChattingActivity::class.java)
startActivity(intent)
}
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
โ dismiss() : ๋ค์ด์ผ๋ก๊ทธ๊ฐ ์ฌ๋ผ์ง
'Android [Kotlin] ๐ป๐ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
android namespace (0) | 2022.01.08 |
---|---|
[Kotlin] Fragment์์ Intent ์ฌ์ฉ (0) | 2021.11.20 |
[Kotlin] EditText์์ ํด๋ฆญ์ด๋ ์์ ๋ง๊ธฐ (0) | 2021.11.19 |
[Kotlin] ScrollView ๋งจ์๋ก ๋ฒํผ ๋๋ฅด๋ฉด ์๋จ์ผ๋ก ๊ฐ๊ธฐ (0) | 2021.11.19 |
[Kotlin] ScrollView ์์ RecyclerView ๋ง๋๋ ๋ฐฉ๋ฒ (0) | 2021.11.19 |
Comments