0
我有一个活动的根布局是一个抽屉布局,主要内容是一个视图分页器(和com.astuetz.viewpager.extensions.PagerSlidingTabStrip协助viewpager。现在我想要做的是在导航抽屉选择特定项目,视图寻呼机(与标签名条沿)获取一个片段取代我的活动布局文件是这样的:交换ViewPager与单个片段
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.astuetz.viewpager.extensions.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip"
android:background="@drawable/background_tab"
app:underlineColor="#E67E22"
app:indicatorColor="#E67E22" />
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs"
tools:context=".UserActivity" >
</android.support.v4.view.ViewPager>
<FrameLayout android:id="@+id/fragmentToSwap"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#666"
android:background="#E8E8E8"
/>
</android.support.v4.widget.DrawerLayout>
现在,这是我努力用片段替换视图寻呼机我对这个我自己也不太确定,有点困惑哪个元素可以替换掉方法
UserProfileActivity userProfileFragment = new UserProfileActivity();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragmentToSwap, userProfileFragment);
transaction.addToBackStack(null);
transaction.commit();
当前正在发生的是新的片段元素与视图寻呼机重叠,而我仍然能够在后台使用视图寻呼机。请帮我弄明白。
这种能见度的工作原理! :D 虽然如你所说,你的第二个想法对我来说也更有意义。当我得到时间并让你知道它是如何发生的时候,我会试试。 (我会接受你的答案后,我试试这个:P) – gitter
它的工作原理:D谢谢 – gitter