我不知道我是否應該創建一個新的線程或不。我已將代碼放在主要活動中,但片段涵蓋了所有活動。 screen of the fragment 這很奇怪,因爲其他片段有效。
主要活動
TestSlideFragment fragment = new TestSlideFragment();
fragmentTransaction.replace(R.id.RelativeLayout_for_Fragment, fragment);
fragmentTransaction.commit();
片段
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="oytoch.iut_info.test.TestSlideFragment">
<!-- TODO: Update blank fragment layout -->
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="match_parent" />
謝謝,你說的佈局 「添加...」 是不是缺少一個字?我會嘗試你的解決方案 –
我已經這麼做了,你說但我的片段顯示在所有活動中,因此我的導航抽屜被隱藏 –