我的菜单项后必须有一个文本视图,它不应该响应。我不需要以编程方式进行更新。我正在使用导航抽屉活动。我可以根据文本创建图像,因此图像视图的实现也会有所帮助。
Kind of like this

最佳答案

我不知道您使用哪种代码和版本来创建导航菜单。但我有3条建议给您。
如果您使用'android.support.design.widget.NavigationView',其中之一就是下面的代码:

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:menu="@menu/menu_drawer">

    </android.support.design.widget.NavigationView>

    <TextView
        android:id="@+id/textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:text="your Sentences" />
</LinearLayout>




如果使用android.support.v4.widget.DrawerLayout,则另一个是下面的代码:

    <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" >

<FrameLayout
    android:id="@+id/content_frame"...../>

<RelativeLayout
    android:id="@+id/relative_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start" >

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <TextView
            android:id="@+id/text_view1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Your Sentences" />

    </RelativeLayout>
</RelativeLayout>

</android.support.v4.widget.DrawerLayout>


最后建议您在菜单中使用其他列表项。在适配器中使用getViewTypeCount()getItemViewType(int position)。见this link

10-04 22:59
查看更多