DialogFragment displays a list of swap icons

In my application, users can send the badge / gift to other users. I want to show a DialogFragment popup that includes swapping the available icons.

For example, I have a total of 15 icons to display. I want to show 6 icons per page, which means that I have to have 3 "pages" to scroll horizontally.

Similar pager

I tried using FragmentPagerAdapter and RecyclerView with GridLayout for icons. But it does not work as if I want to.

How can this be implemented using the PagerAdapter without any fragments?

+5
source share
3 answers

If you don’t want to use snippets, try the normal work using the dialog theme. eg; <activity android:name="your_activity_name" android:theme="@android:style/Theme.Dialog" />

+4
source
  • Create a DialogFragment dialog with the ViewPager indicator and Pager in it (according to your design).
  • Add a PagerAdapter for the ViewPager.
  • Create a layout and add a RecyclerView to it.
  • Now use this layout created in step 3 in the PagerAdapter and inside the PagerAdapter, set the Adapter for recyclerview with the GridLayoutManager and horizontal orientation and show 6 items from your list.
+3
source

You can use three pages, each of which contains a RecyclerView , each page is a custom view instead of a fragment. But you should still use ViewPager to navigate pages

0
source

Source: https://habr.com/ru/post/1259460/


All Articles