K
K
Kostya Bakay2016-04-10 17:01:28
Android
Kostya Bakay, 2016-04-10 17:01:28

Is it possible to dynamically change the first element in a ViewPager to another fragment?

My application has a ViewPager that consists of two fragments: the first fragment is a list of songs, and the second one is the playback display of the selected song. So it turns out that the list in the application will not be one (all songs, favorite songs, etc.), but the ViewPager should remain as it is. Simply put, I want to change the first fragment for the ViewPager when selecting a list from the Navigation Drawer, but not touching the second one. For example, if you select all songs, you get a list of these songs in the first slide of the ViewPager, and when you select a song, you go to the second slide to play it. I chose my favorite songs from the curtain - their list is loaded in the first slide of the ViewPager, and when an element is selected, the transition to the second slide for a specific song, and so on. How can I do this replacement of the first fragment?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kostya Bakay, 2016-04-10
@kostyabakay

The problem was solved based on this example. The code can be found here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question