-1

我在各處搜索了一個解決方案,但是我沒有找到任何東西,所以我需要再多一次的幫助。把ViewPager放在菜單抽屜的片段Android

我有一個抽屜式導航誰的作品完美 Navigation drawer

我也有一個ViewPager,我已經走在Android開發者網站。它也可以正常工作。

現在我想將PageViewer放在我的「jour」標籤中作爲例子。但PageViewer是不是一個「片段」,而是「ActivityFragment」所以我不能。我可以找到其他線程一點兒也不相配,以我的問題

我怎麼能做到這一點的幫助?

非常感謝您的閱讀。

附件: 教程安卓:https://developer.android.com/training/animation/screen-slide.html

回答

0

打開怨婦的XML,並添加ViewPager標籤。

然後打開Jour的java並將ViewPager的一個對象與xml綁定。將適配器添加到viewpager對象並完成。

+0

謝謝,你說的佈局 「添加...」 是不是缺少一個字?我會嘗試你的解決方案 –

+0

我已經這麼做了,你說但我的片段顯示在所有活動中,因此我的導航抽屜被隱藏 –

0

我不知道我是否應該創建一個新的線程或不。我已將代碼放在主要活動中,但片段涵蓋了所有活動。 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" /> 

+0

在您的TestSlidefragment中,添加ViewPager實例並設置一個適配器。 –

+0

我真的迷失了,對不起。我將依靠您的解決方案來解決這個問題。非常感謝你的幫助。祝你有美好的一天。 –