Deepak Rana
Deepak Rana

Reputation: 549

Navigation component for Custom navigation Drawer

I am using Navigation Component library. But now i am getting stuck at one point. i have created custom navigation drawer with recycler view . Now i want to move to the next fragment on adapter item click. How can achieve that with Navigation Component libarary.

Here is my adapter item click. Here i have tried to create navigation click but its not working.

override fun onItemClick(view: View, position: Int) {
    when(position){
        0->{
            Navigation.createNavigateOnClickListener(R.id.homeFragment)
            binding!!.drawerLayout.closeDrawer(GravityCompat.START)
        }

        1->{

        }
    }
}

Upvotes: 4

Views: 363

Answers (1)

Hussnain Haidar
Hussnain Haidar

Reputation: 2258

Use

Navigation.findNavController(view).navigate(R.id.homeFragment)

Upvotes: 1

Related Questions