Groupie: Passing NavHost to findNavController

Created on 26 Mar 2019  路  1Comment  路  Source: lisawray/groupie

I'm not sure if I'm describing the issue properly, s I'll be happy to give more information with some guidance.

I have a recyclerView that I'm implementing using groupie.

Each element contains a few buttons, and one should navigate to a new fragment.

I've implemented navigation using the navigation graph.

when trying to use

findNavController().navigate(action)

As I usually would, it doesn't work.

I've tried viewHolder.root.findNavController().navigate(action)

And it doesn't work either.

I keep getting this error:

navigation destination XXXXX is unknown to this NavController
How can I bridge it to make it work?

invalid

Most helpful comment

@Tsabary hey, first of all - this is not a library issue, but your own. Define a listener for your scenario. So whenever you tap on a button that navigates to a different screen, your fragment will handle that, no need to pass "NavHost" anywhere. In other words, recycler will tell it's parent, which is fragment or activity or whatever, that user tapped on the button.

>All comments

@Tsabary hey, first of all - this is not a library issue, but your own. Define a listener for your scenario. So whenever you tap on a button that navigates to a different screen, your fragment will handle that, no need to pass "NavHost" anywhere. In other words, recycler will tell it's parent, which is fragment or activity or whatever, that user tapped on the button.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValCanBuild picture ValCanBuild  路  5Comments

MirzaAhmedBaig picture MirzaAhmedBaig  路  6Comments

ValCanBuild picture ValCanBuild  路  6Comments

punitda picture punitda  路  3Comments

amervelic picture amervelic  路  3Comments