我有一个活动,并且很多片段都膨胀了 FrameLayout
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
示例:mainActivity>任何片段(按返回按钮)>活动为空白。
在onCreate中:
layout = (FrameLayout)findViewById(R.id.content_frame);
layout.setVisibility(View.GONE);
当我开始片段时:
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, profileFragment);
ft.addToBackStack(null);
ft.commit();
layout.setVisibility(View.VISIBLE);
我想我需要GONE
再次按一下frameLayout的可见性,但是我该怎么做呢?
我尝试onBackPressed
并设置,layout.setVisibility(View.GONE);
但是无法直接浏览片段,因为我直接进入主页。