How can I show two arrays in the same fragment?

0

I'm trying to do a Array with different categories to show them in the same fragment , the problem is that it only shows me a Array and not both. I would like to know if it can be done like this or there is another way.

This is my code where I want to put the two Array :

public class FragmentNovedades extends Fragment  {

public RecyclerView recyclerView;
public LinearLayoutManager linearLayout;

public FragmentNovedades() {    }


  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                     Bundle savedInstanceState) {

  View view = inflater.inflate(R.layout.fragment_novedades, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
linearLayout = new LinearLayoutManager(getActivity());
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(linearLayout);

ListaAdaptador adapter = new ListaAdaptador(getContext(),ListaObjetos.getCourses());
recyclerView.setAdapter(adapter);

 //esta es la segunda lista que quiero meter pero solo me muestra la de 
 arriba

 ListaAdaptadorVideo adaptervideo=new 
 ListaAdaptadorVideo(getContext(),ListaObjetosVideo.getVideos());
 recyclerView.setAdapter(adaptervideo);

  return view;

 } 
  }

When I put the following two lines it does not show me both lists (only one), how can I do it to show the two ?:

ListaAdaptador adapter = new ListaAdaptador(getContext(), 
ListaObjetos.getCourses());
ListaAdaptadorVideo adaptervideo=new ListaAdaptadorVideo(getContext(), 
ListaObjetosVideo.getVideos());
    
asked by Carlos Mario 27.06.2017 в 21:45
source

1 answer

0

The problem is that you have a unique recyclerView , and to this element you try to set 2 different adapters. Note that a single recyclerView instances.

...public RecyclerView recyclerView, recyclerViewVideo;...

And then you associate them with the same element of the view when you should have 2:

recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerViewVideo = (RecyclerView) view.findViewById(R.id.recycler_view_video);

And then instances each adapter in the corresponding.

I hope it serves you.

    
answered by 27.06.2017 / 22:05
source