как я могу запустить фрагмент внутри фрагмента в Android? Я разрабатываю новое приложение, в котором пользователь нажимает на иконку во фрагменте, и когда пользователь нажимает на иконку, я хочу начать новое действие, но я не понял, как это работает в kotlin ниже моего кодав StartFragmentSession
if(it.key.endsWith("_rf")) {
attentionIcon.setColorFilter(ContextCompat.getColor(context!!, R.color.therapyInfoRedFlag))
attentionIcon.setOnClickListener {
val newFragment = TherapyInformationFragment()
val transaction = childFragmentManager.beginTransaction()
transaction.replace(R.id.therapy_fragment, newFragment)
transaction.addToBackStack(null)
transaction.commit()
}
} else if(it.key.endsWith("_yf")) {
attentionIcon.setImageResource(
R.drawable.ic_therapy_info_yellow_flag_attention
)
attentionIcon.setColorFilter(ContextCompat.getColor(context!!, R.color.therapyInfoYellowWhiteFlag))
attentionIcon.setOnClickListener {
val newFragment = TherapyInformationFragment()
val transaction = childFragmentManager.beginTransaction()
transaction.replace(R.id.therapy_fragment, newFragment)
transaction.addToBackStack(null)
transaction.commit()
}
} else {
attentionIcon.setImageResource(
R.drawable.ic_therapy_info_yellow_flag_attention
)
attentionIcon.setColorFilter(ContextCompat.getColor(context!!, R.color.therapyInfoYellowWhiteFlag))
attentionIcon.setOnClickListener {
val newFragment = TherapyInformationFragment()
val transaction = childFragmentManager.beginTransaction()
transaction.replace(R.id.therapy_fragment, newFragment)
transaction.addToBackStack(null)
transaction.commit()
}
}
я хочу начать с TherapyInformationFragment, когда пользователь нажимает на иконку