【问题标题】:how to make navigation drawer without listview如何在没有列表视图的情况下制作导航抽屉
【发布时间】:2014-03-17 16:44:02
【问题描述】:

有谁知道如何替换 navigationDrawer 中的列表视图? 我不知道如何在没有 listView 的情况下使用导航抽屉。 我想放 imagenButtons 并且我会使用 setonclickListener 去一个片段。 我想把样子

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- The main content view -->

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<LinearLayout
    android:id="@+id/tab_route_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:id="@+id/imageButton3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:id="@+id/imageButton4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />




</LinearLayout>

我想使用 imageButton.setOnClickListener 但我不知道。 同人有什么想法吗?

【问题讨论】:

    标签: android listview navigation-drawer


    【解决方案1】:
    FrameLayout contentFragme = findViewById(R.id.content_frame);
    content_frame.findViewById(R.id.imageButton1).setOnClickListener(this);
    

    然后根据它们的 id 更改onClick() 中的片段。 给你。

    【讨论】:

    • 将 android:layout_gravity="start" 添加到您的 LinearLayout 中,这样 android 将寻找该空间将其设置为您的抽屉,并按照 nikola 所说的做,但我认为应该是 LinearLayour , FrameLayout 会是你视图的内容,你也可以一直直接调用按钮
    猜你喜欢
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    • 1970-01-01
    相关资源
    最近更新 更多