A
A
Alexander Koshelev2022-03-12 14:56:38
Kotlin
Alexander Koshelev, 2022-03-12 14:56:38

How to start a new fragment from a fragment?

Good day to all.
In short: I have a fragment (the main screen of the application) and in this fragment (screen) I have 4 textViews, when clicked, I need to launch other corresponding fragments.

private fun addListeners(view: View){
        view.setOnClickListener(object : View.OnClickListener{
            override fun onClick(p0: View?) {
                when(view?.id){
                    R.id.textView1 -> {
                        parentFragmentManager.fragments.
                    }
                }
            }
        })
    }

That is, call a fragment from a fragment. a normal manager fragment cannot be launched from a fragment. How can I resolve this issue? That is, I hung up a listener that looks at the id of the clicked textView and launches the corresponding fragment!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question