相关疑难解决方法(0)

如何将列表项放在导航抽屉列表视图的底部,如Foursquare

我得到了导航抽屉的列表视图,如何在列表视图的底部放置"添加好友"列表项,"设置"对齐.

在此输入图像描述

更新1
我在页脚视图中添加了设置视图.

View settingView = getLayoutInflater().inflate(R.layout.drawer_list_item, null);
TextView textView = (TextView)settingView.findViewById(R.id.drawer_list_item_text_view);
textView.setText("Settings");
drawerListView.addFooterView(settingView); 
Run Code Online (Sandbox Code Playgroud)

设置项成功显示在列表视图中的最后一个项目上.但是我怎样才能让它在底部粘住并对齐?谢谢.

android android-listview navigation-drawer

18
推荐指数
1
解决办法
1万
查看次数

向导航抽屉添加线性布局(最终导致与ClassCastException崩溃)

我试图在导航抽屉中添加垂直线性布局(标题,图像,菜单标题,列表视图和底部的图标).然而,应用程序崩溃显示

'java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams'
Run Code Online (Sandbox Code Playgroud)

错误.我不确定这是否可能是直接的方式,因为我检查了几个链接,我得到的唯一关闭是这个.任何帮助表示赞赏.提前致谢.这是我的代码.

<!-- The main context view -->

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

<!-- The navigation drawer -->

<LinearLayout        
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#fff"
    android:gravity="bottom|center"
    android:orientation="vertical"
    android:paddingTop="30dp" >

    <ListView
        android:id="@+id/left_drawer"                        
        android:choiceMode="singleChoice"
        android:divider="#E8E8E8"
        android:dividerHeight="1dp"
        android:footerDividersEnabled="false"
        android:headerDividersEnabled="false" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:padding="10dp"
        android:src="@drawable/footer_image" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在的问题是,xml不允许我为listview定义宽度和高度(Element未知),我也无法运行它,因为编译器说"你必须提供layout_width"属性?请帮忙.

我的代码与scrollview.

<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 context view -->

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

<!-- The navigation drawer -->

<ScrollView
    android:id="@+id/leftRL"
    android:layout_width="240dp"
    android:layout_height="match_parent" …
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer

7
推荐指数
3
解决办法
2万
查看次数