|
1
|
getSupportFragmentManager().popBackStack(); |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
//
打开播放列表private void btnClick_playinglist(){ FragmentTransaction
ft = getSupportFragmentManager().beginTransaction(); Fragment
fragment = new PlayingListFragment(); if (isOpenPlayingList)//播放类表是否已打开 { getSupportFragmentManager().popBackStack(); mPlaying_img_openlist.setImageResource(R.drawable.icon_playing_img_openlist); isOpenPlayingList
= false; } else { ft.hide(mFragment); ft.add(R.id.playing_fragment_layout,
fragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); mFragment
= fragment; mPlaying_img_openlist.setImageResource(R.drawable.icon_playing_img_openlist_press); isOpenPlayingList
= true; } ft.commit();} |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//重写监听back键按钮@Overridepublic void onBackPressed(){ getSupportFragmentManager().popBackStack(); if (isOpenPlayingList)//判断播放列表是否打开 { mPlaying_img_openlist.setImageResource(R.drawable.icon_playing_img_openlist); isOpenPlayingList
= false; } else { super.onBackPressed(); }} |
本文探讨了使用Fragment进行界面切换时遇到的问题及其解决方案,包括如何正确更新界面数据、避免界面空白以及同步更新数据的方法。
114

被折叠的 条评论
为什么被折叠?



