I'm new to fragments and I have built a simple app which can play mp3.
So I have one FragmentActivity
containing TabFragments
.
One TabFragment
is a ListFragment
which contains a list of songs, and the other one is a Fragment which displays the music player.
I can play music when I open the app, but when I click some song in the List, I have no idea how to open the "Play Music" Fragment and play the song I clicked.
Help me to solve this problem.
Asked
Active
Viewed 1,002 times
-1

Narendra Baratam
- 828
- 1
- 12
- 26

kien.nt
- 81
- 2
- 12
1 Answers
0
Try this:
int tabIndex = 3;
ActionBar actionBar = getActivity().getActionBar();
actionBar.selectTab(actionBar.getTabAt(tabIndex));
Where tabIndex
is the index of your music player tab.

Simas
- 43,548
- 10
- 88
- 116
-
Thank guy. But your answer is just calling PlayMusic tab. I want to play musing song when I clicked song in the list of ListFragment. – kien.nt Oct 26 '14 at 04:11