2
I have a Ragment that is inflating a Recycler view, so far so good. The problem is that this Fragment needs to inflate into two different Rawer navigation, and when it comes to casting, I can only cast for one of them.
Is there any way that when it comes to casting, he can identify which class is calling Fragment, and cast that particular class?
Below is the code that is giving error.
comunicadosList = ((NvdResp) getActivity()).getSetComunicadosList(3);
ComunicadosAdapter adapter = new ComunicadosAdapter(getActivity(), comunicadosList);
recyclerView.setAdapter(adapter);
in addition to the Nvdresp class (which I cast to search my list for the items to be inflated) I also have the Nvdaluno class. I could create a generic class or something?
I think using this casting scheme for what you’re doing is not ideal. I think you should do it using interface. By the way, I also find it strange to use Fragments in a Recyclerview. Don’t know a custom view there?
– Lucas Lima
Actually Fragment is inflating Recyclerview inside the Navigationdrawer. the problem is that my application works with two profiles student and responsible, and precisely this Fragment needs to be inflated in the two Navigationdrawer, only if I put in a Navigationdrawer (in the case of the Nvdresp example) the other Navigationdrawer (in the case of Nvdaluno) from the cast error, I was thinking of creating a new class and putting my List on it and casting for that class, then instantiating the class inside my Navigationdrawer.
– Brendon Iwata
I’ve never worked with Customview, I’ll give you a search, you know you can never have too much knowledge ; - )
– Brendon Iwata