Я хочу знать, Как я могу написать код без приведения активности как фрагмент? ....
--------- Фрагмент
tempMainImage.setOnClickListener {
val message = "how are you today"
(activity as? MainActivity).let {
it?.onReplaceTtsFragment(message)
}
}
---------- MainActivity
fun onCloseTtsFragmentLayout() {
detailFragmentLayout.visibility = View.GONE
}
fun onReplaceTtsFragment(message: String) {
supportFragmentManager.beginTransaction().replace(R.id.detailFragmentLayout, TtsDetailFragment.newInstance(message, ::onCloseTtsFragmentLayout)).commit()
detailFragmentLayout.visibility = View.VISIBLE
}