DialogFragment display a list of icons with paging - android

In my app, users can send an icon/gift to other users. I want to show a DialogFragment popup that includes paging of available icons.
For example, I have a total of 15 icons to display. I want to show 6 icons per page, which means i should have 3 "pages" to swipe through horizontally.
I tried using a FragmentPagerAdapter and RecyclerView with GridLayout for the icons. But it's not really working like i want it.
How can this be implemented using a PagerAdapter without any fragments?

If you dont want to use fragments then try with a normal activity with a dialog theme. eg; <activity android:name="your_activity_name" android:theme="#android:style/Theme.Dialog" />

Create a DialogFragment with ViewPager and Pager Indicator in it (as per your design).
Add a PagerAdapter for the ViewPager.
Create a layout and add the RecyclerView in it.
Now use that layout created in 3rd Step in PagerAdapter and inside PagerAdapter, set Adapter for recyclerview with GridLayoutManager and Horizontal Orientation and show the 6 items from your list.

You can use three pages each containing a RecyclerView, each page is a custom view instead of a fragment.
But you still have to use the ViewPager to navigate through the pages

Related

What is the correct way to approach ViewPager and Fragments when number of fragments are more than 50 but each of them has same layout and methods?

I am making an app which has a navigation drawer. This navigation drawer has 50 menu items. These items have the same layout, same activity but different data.
I want to implement ViewPager in my app so that the user could swipe left and right (manually and automatically).
Issue: I am facing an issue of how to implement this. The activity (for these menu items) has its own methods and functionality. A ViewPager can slide fragments but my issue is that since all of these menu items have the same layout and functionality then it would be much better to use one fragment whose data change with swipes for each menu items.
I don't know how to approach this. Please guide me.
You can do it by using a recycleView,and you will need an arrayAdapter which will help you adapt the data accordingly and you will need to have a separate class that will have all the data you want, you can also have different constructor in that class. You can check this to know more https://www.codexpedia.com/android/a-very-simple-example-of-android-recyclerview/

Swipe between tabs when the layouts are the same

I want to add two tabs to my Android app.
Tab 1: To do tasks
Tab 2: Done tasks
The layout in both views is the same (the only thing changing is the data shown). It's a gridlayout with cardviews.
How can I implement the tab/swipe action that changes from one to another being both the same .xml?
Android documentation is outdated and many of the methods used here are deprecated.
You can use viewPager and tabLayout for that swipefeature and call your fragments through custom adapter by extanding FragmentPagerAdapter in that
.

How to implement horizontal view android studio

im trying to implement an android aplication when your activity, cointains 3 or more 'main windows' like in the image -> 'A'. 'B'.'C'. so how is posible make when you slide you touch screen change from A, to B, for example, i was thinkin in a horizontal view, and inside of each item use a relative layout, but im not sure, its my first time with this kind of problem, thanks.
Try using android ViewPager. Each ImageView would be inside a Fragment that would reside inside your Activity. Check out this example
Use Tabbed Activity template when you want to make this type of Activity. ViewPager, Adapter and tab layout will be automatically implemented for you. Just make small changes in your Adapter according to your needs and use one Fragment for one tab and you can create as many tabs as you want in an Activity.
If you want i will post an example of an Adapter as i just implemented an Activity with 3 tabs.
To get your basics strong on ViewPager, tab layout and Fragment sections adapter read out this link.

Android Studio how to swipe through pages?

Lets keep it really simple. Say I created 4 layout's called page_one, page_two, page_three, page_four. How can you make it so you can swipe through all those pages back and forth horizontally?
You can use a View Pager to achieve this.
you can swipe through the pages by using a view pager.
you can go through this link
http://developer.android.com/training/animation/screen-slide.html
Edit:
1) Create 4 layouts for 4 fragments view.
2) Create a activity which extends FragmentActivity.
3) Create an adapter for view pager and set the adapter in your main method.
4) You can use tabs also for this.

Manually load the fragment in FragmentActivity

I want Horizontal as well as vertical swipe using the ViewPager.I implemented it using the Vertical view pager in which I used the fragments for the vertical swipe and in that fragments, used ViewPager for the horizontal swipe.
I took help from below link for vertical swipe:
https://github.com/LambergaR/VerticalViewPager/
and http://manishkpr.webheavens.com/android-viewpager-as-image-slide-gallery-swipe-gallery/ for horizontal swipe.
Problem:
I have three image adapters and three fragments, one for each image adapter. These three fragments are inside one FragmentActivity. When this FragmentActivity is created I want to manually select which fragment should be displayed. Here, the three fragments contains data with three different languages. Now I want to load the fragment of particular language specified by the user. Any example or a code snippet will help me implement this functionality.
Thanks in advance :)

Categories

Resources