我尝试打开另一个对话框片段,代码如下:
private fun showList() {
val job = Job()
val scopeMainThread = CoroutineScope(job + Dispatchers.Main)
val scopeIO = CoroutineScope(job + Dispatchers.IO)
val adapter = ServerListAdapter()
val recyclerView = binding.rvConnList
binding.rvConnList.addItemDecoration(
DividerItemDecoration(
activity,
DividerItemDecoration.VERTICAL
)
)
recyclerView.adapter = adapter
recyclerView.layoutManager = GridLayoutManager(activity, 1)
val serverViewModel= ViewModelProvider(this)[ServerViewModel::class.java]
scopeIO.launch {
val x = serverViewModel.getAll()
scopeMainThread.launch {
activity?.let {
x.observe(it) { s ->
s?.let { it ->
adapter.setData(it)
adapter.onItemClick = {
SyncSovEntryFragment(Date(), it).apply {
setListener { _, year, month, dayOfMonth ->
Toast.makeText(requireContext(), "Set date: $year/$month/$dayOfMonth", Toast.LENGTH_LONG).show()
}
activity?.let { it1 -> show(it1.supportFragmentManager, "MonthYearPickerDialog") }
}
Toast.makeText(activity, it.database, Toast.LENGTH_LONG).show()
dismiss()
}
}
}
}
}
}
}
我正在尝试打开另一个对话框片段,是否有其他方法可以在对话框片段中调用supportFragmentManager?因为以下代码不起作用:
活动?.let {it 1-〉show(it1.supportFragmentManager,“月/年选取器对话框”)}
谢谢你,谢谢。
1条答案
按热度按时间72qzrwbm1#
打开适配器中Activity或片段,如下所示
itemlayout是您的recycler的主布局查看要单击的项目