繁体   English   中英

如何使我的导航抽屉中的一项成为ExpandableListView?

[英]How to make one of the item of my navigation drawer as an ExpandableListView?

我想将导航抽屉中的一项作为expendableListView,我了解ExpendableListView,但不知道如何将其集成到导航抽屉中,特别是使其看起来像导航抽屉中的其他项。

这样尝试

<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"
android:background="@android:color/white"
android:fitsSystemWindows="true">

<include layout="@layout/home_content" />

 <android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start|top"
    android:background="@android:color/white"
    android:fitsSystemWindows="false">

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

   <ExpandableListView
        android:id="@+id/lvExp1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.5"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:groupIndicator="@null"
        android:scrollbars="none" />
   </LinearLayout>

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

更新:在您的groupExpandListener写入条件上

expandedListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
            @Override
            public void onGroupExpand(int groupPosition) {

                if (groupPosition == 0) { // EXPAND
                    expandedListView.collapseGroup(groupPosition);
                } else if(groupPosition != 0 {
                    // Intent...
                    // Do your stuff
                }  
            }
        });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM