滑动抽屉中addHeaderView的ListView控件 [英] Sliding drawer in addHeaderView for ListView

查看:126
本文介绍了滑动抽屉中addHeaderView的ListView控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一次是有点复杂。这里就是我要做的。

This once is bit complicated.. Here is what I am trying to do.

我有一个列表视图。我想用addHeaderView到SlidingDrawer添加到该ListView的。

I have a list view. I want to add SlidingDrawer to this listView using addHeaderView.

但由于某些原因,我不断收到这种

But for some reason I keep getting this

cannot have UNSPECIFIED dimensions

下面是XML的

这是我使用我的活动

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        <ListView 
            android:id="@+id/userReviews"
            android:layout_alignParentTop="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>

</RelativeLayout>

然后我使用下面的XML加载为列表视图

Then I am using following XML to load as a header for list view

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/details_header"
    android:layout_width="fill_parent"
    android:padding="7dip"
    android:layout_height="wrap_content">
    <TextView 
        android:id="@+id/listingName"
        android:layout_alignParentTop="true"
        android:textSize="20dp"
        android:textStyle="bold"
        android:padding="2dip"
        android:singleLine="true"
        android:textColor="@android:color/white"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="Listing Name"/>
    <TextView 
        android:id="@+id/reviewTitle"
        android:layout_alignParentRight="true"
        android:textSize="14dp"
        android:layout_below="@id/listingRating"
        android:textColor="@android:color/white"
        android:singleLine="true"
        android:textStyle="bold"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/darker_gray"
        android:text="User Reviews:"/>
        <SlidingDrawer android:id="@+id/slidingDrawer1"
                android:layout_width="match_parent" android:layout_height="match_parent"
                android:topOffset="50dip" android:handle="@+id/handle"
                android:content="@+id/content">
                <Button android:text="Handle" android:layout_height="wrap_content"
                        android:layout_width="wrap_content" android:id="@+id/handle"></Button>
                <LinearLayout android:id="@+id/content"
                        android:layout_width="fill_parent" android:layout_height="fill_parent"
                        android:orientation="vertical" android:gravity="center"
                        android:background="#FF444444">
                        <Button android:text="Item 1" android:layout_height="wrap_content"
                                android:layout_width="wrap_content" android:id="@+id/item1"></Button>
                        <Button android:text="Item 2" android:layout_height="wrap_content"
                                android:layout_width="wrap_content" android:id="@+id/item2"></Button>
                        <Button android:text="Item 3" android:layout_height="wrap_content"
                                android:layout_width="wrap_content" android:id="@+id/item3"></Button>
                        <Button android:text="Item 4" android:layout_height="wrap_content"
                                android:layout_width="wrap_content" android:id="@+id/item4"></Button>
                        <Button android:text="Item 5" android:layout_height="wrap_content"
                                android:layout_width="wrap_content" android:id="@+id/item5"></Button>
                </LinearLayout>
        </SlidingDrawer>
</RelativeLayout>

但是,一旦我运行这个code,它给我的错误

But as soon as I run this code, it gives me error

10-26 18:41:05.652: E/AndroidRuntime(3734): java.lang.RuntimeException: SlidingDrawer cannot have UNSPECIFIED dimensions
10-26 18:41:05.652: E/AndroidRuntime(3734):     at android.widget.SlidingDrawer.onMeasure(SlidingDrawer.java:261)

一些指针会帮我很多......

SOme pointer will help me a lot.....

推荐答案

该解决方案是摆在该活动的Andr​​oid清单:

The solution is put in the android Manifest in the activity:

android:windowSoftInputMode="adjustPan"

这篇关于滑动抽屉中addHeaderView的ListView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆