[英]Swiping Tabs inside a Navigation Drawer Fragment
我已經通過參考本教程實現了導航抽屜,現在我想要做的是在片段內顯示滑動標簽。 即。 當我點擊導航抽屜中的某個項目時,讓我們說第一個項目,它應顯示該項目的滑動標簽。
如果item1是Events,當我點擊它時,它應該顯示滑動選項卡,其中包含今日事件和即將發生的事件等選項卡。 我是一個初學者,我試圖谷歌為此,我找到的解決方案是使用sherlock,但我不想使用任何庫。 請指出一個正確的教程。 我可以在片段內實現視圖尋呼機。 鑒於視圖尋呼機將有兩個以上的片段。
謝謝。
這是我在評論中談論的抽屜的一個例子。 如果您具有抽屜布局並且子項為listview和viewpager,則布局將如下所示:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
tools:context=".MainActivity" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- This List View for the sliding menu -->
<LinearLayout
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:orientation="vertical" >
<!-- If you want to add some more things to your navigation drawer -->
<!-- <EditText
android:id="@+id/search_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:hint="Search"
android:maxLines="1" >
</EditText> -->
<ListView
android:id="@+id/list_slidermenu_child"
android:layout_width="250dp"
android:layout_height="match_parent"
android:background="#303030"
android:choiceMode="singleChoice"
android:divider="#272727"
android:dividerHeight="3dp"
android:listSelector="@drawable/list_selector"
android:padding="5dp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
這就是你的布局的樣子:
測試圖像http://imageshack.com/a/img22/9166/qh8h.png
現在,在我的示例中,當我單擊列表中的任何項目時,視圖尋呼機設置它應該是的視圖。
這是你想要的嗎?
這是一張新圖片:
測試圖像http://imageshack.com/a/img600/4421/2khw.png
點擊導航中的任何項目,它會在后面的視圖上顯示該內容?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.