FAIL
var fragmentDialog = ListFragmentDialog().newInstance(
it,
type,
object :
ListFragmentDialog.OnButtonClickListener {
override fun onConfirmButtonClicked() {
when (type) {
Type.TESTJSON -> setTFieldInfo()
Type.BUSINESSLOGIC -> loadPaperless()
}
}
}
)
fragmentDialog.show(supportFragmentManager, "ListFragmentDialog")
MainActivity.kt
private var _binding: FragmentListDialogBinding? = null
private val binding get() = _binding!!
private lateinit var _list: Array<String>
private lateinit var _type: Type
private lateinit var _listener: OnButtonClickListener
fun newInstance(
list: Array<String>,
type: Type,
listener: OnButtonClickListener
): ListFragmentDialog {
val args = Bundle()
val fragment = ListFragmentDialog()
fragment.arguments = args
_list = list
_type = type
_listener = listener
return fragment
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentListDialogBinding.inflate(inflater, container, false)
binding.confirm.setOnClickListener {
_listener?.onConfirmButtonClicked()
dismiss()
}
binding.cancel.setOnClickListener { dismiss() }
return binding.root
}
ListFragmentDialog.kt
SUCCESS
var fragmentDialog = ListFragmentDialog().newInstance(
it,
type
)
fragmentDialog.setOnButtonClickListener(object :
ListFragmentDialog.OnButtonClickListener {
override fun onConfirmButtonClicked() {
when (type) {
Type.TESTJSON -> setTFieldInfo()
Type.BUSINESSLOGIC -> loadPaperless()
}
}
})
fragmentDialog.show(supportFragmentManager, "ListFragmentDialog")
MainActivity.kt
private var _binding: FragmentListDialogBinding? = null
private val binding get() = _binding!!
private lateinit var _list: Array<String>
private lateinit var _type: Type
private lateinit var _listener: OnButtonClickListener
fun newInstance(
list: Array<String>,
type: Type
): ListFragmentDialog {
val args = Bundle()
val fragment = ListFragmentDialog()
fragment.arguments = args
_list = list
_type = type
return fragment
}
//setter 로 추가
fun setOnButtonClickListener(
listener: OnButtonClickListener
) {
_listener = listener
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentListDialogBinding.inflate(inflater, container, false)
binding.confirm.setOnClickListener {
_listener?.onConfirmButtonClicked()
dismiss()
}
binding.cancel.setOnClickListener { dismiss() }
return binding.root
}
ListFragmentDialog.kt
---> 나중에 함 찾아보기
반응형
'Platform > Android' 카테고리의 다른 글
[WebView] Android SDK 버전별 WebView 버전 확인 (0) | 2021.07.27 |
---|---|
[gradle] ViewBinding 추가 (0) | 2021.07.25 |
[Kotlin] 기초 (0) | 2021.07.21 |
[Error] Cannot fit requested classes in a single dex file (0) | 2021.07.21 |
[CleanArchitecture] 앱 아키텍처 가이드 (0) | 2021.06.23 |