Issue
I want the fragment_yetki.xml file to be opened when the yetki_modulu_cardView in the fragment_mudur_home.xml is clicked. How can I do this from within the MudurHomeFragment.kt class?
Solution
For that first you have to create an action in the mobile_navigation page. Like this
`<fragment
android:id="@+id/titleFragment"
android:name="com.dheeraj.guessbro.title.TitleFragment"
android:label="title_fragment"
tools:layout="@layout/title_fragment">
**<action
android:id="@+id/action_titleFragment_to_gameFragment"
app:destination="@id/gameFragment" />**
</fragment>'
and then go to the MudurHomeFragment.kt file and just use this code :
binding.yetki_modulu_cardView.setOnClickListener { findNavController(this).navigate(R.id.action_titleFragment_to_gameFragment) }
If you are not using view binding then you can first define the variable using findViewById and then use the clickListener.
Answered By - Dheeraj Mehra
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.