-1

So, basically, I have a fragment and in this fragment, I'd like to implement a ViewPager that allows the user to scroll between cards, (btw I ask you what I should use to make these), but I know that the ViewPager it can be used only inside activities, so how could I manage to do that?

I've added the ViewPager in the XML file of the fragment, but then I got stuck when it comes to adding the ViewPager object in the java code and to associate it with the cards.

1 Answers1

0

Since using a ViewPager inside a fragment is a headache. Maybe you can try using a RecyclerView with a horizontal orientation. Something like this:

LinearLayoutManager layoutManager
    = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);

RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);

more on this here: How to build a Horizontal ListView with RecyclerView?

Aaron Ayalew
  • 113
  • 10