滚动视图不工作在列表视图视图、列表、工作

由网友(说不出的悲凉╮谁会懂﹏)分享简介:我在此布局。滚动视图多元线性布局工作时,我完全滚动的项目,而不是在列表view.My列表视图中有多个列表项就只显示一个列表项的时间感谢帮助我...... < XML版本=1.0编码=UTF-8&GT?;<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/...

我在此布局。滚动视图多元线性布局工作时,我完全滚动的项目,而不是在列表view.My列表视图中有多个列表项就只显示一个列表项的时间感谢帮助我......

 < XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / taskscrollviewid
    机器人:layout_width =match_parent
    机器人:layout_height =FILL_PARENT>

    <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:方向=垂直
        机器人:滚动条=垂直>

        <的LinearLayout
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =10dp
            机器人:方向=横向
            机器人:weightSum =2>

            <按钮
                机器人:ID =@ + ID / txtdate
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector/>

            <按钮
                机器人:ID =@ + ID / btnTaskTimeid
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector/>
        < / LinearLayout中>

        <的FrameLayout
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =10dp
            机器人:方向=横向>

            <的EditText
                机器人:ID =@ + ID / txtItem
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@可绘制/ edittextselector
                机器人:drawableEnd =@可绘制/收件箱
                机器人:重力=顶|左
                机器人:提示=输入任务
                机器人:inputType =textMultiLine
                机器人:MAXLINES =5
                安卓的minlines =3
                机器人:滚动条=垂直
                机器人:单线=FALSE/>

            <的ImageButton
                机器人:ID =@ + ID / imagebuttonid
                机器人:layout_width =31dp
                机器人:layout_height =36dp
                机器人:layout_gravity =右|底
                机器人:背景=@可绘制/收件箱/>
        < /的FrameLayout>

        <的LinearLayout
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =10dp
            机器人:方向=横向
            机器人:weightSum =2>

            <按钮
                机器人:ID =@ + ID / btnaddcategoryid
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector
                机器人:文本=AddCategory/>

            <按钮
                机器人:ID =@ + ID / btnaddseverityid
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector
                机器人:文本=AddSeverity/>
        < / LinearLayout中>

        <按钮
            机器人:ID =@ + ID / btnadddb
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =30像素
            机器人:layout_gravity =中心| center_horizo​​ntal
            机器人:layout_marginTop =10dp
            机器人:背景=@可绘制/ taskbuttonselector
            机器人:文本=添加该任务/>

        <的LinearLayout
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =10dp
            机器人:方向=横向
            机器人:weightSum =2>

            <按钮
                机器人:ID =@ + ID / fillbut
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector
                机器人:文本=留任务/>

            <按钮
                机器人:ID =@ + ID / remainbut
                机器人:layout_width =0dip
                机器人:layout_height =30像素
                机器人:layout_weight =1
                机器人:背景=@可绘制/ taskbuttonselector
                机器人:文本=完成任务/>
        < / LinearLayout中>

        <的ListView
            机器人:ID =@ + ID / listid
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =10dp
            机器人:可点击=真
            机器人:方向=垂直>
        < / ListView控件>
    < / LinearLayout中>

< /滚动型>
 

解决方案

从来没有把一个列表视图滚动视图,反之亦然里面!它是这么说的就在文档:

  

您永远不应该使用滚动型与一个ListView,因为ListView的利用了自己的垂直滚动护理。最重要的是,这样做违背了所有的ListView重要的优化处理大型列表,因为它有效地强制ListView控件显示项目的整个列表,以填补由滚动型提供了无限的容器。

UG如何在工作界面里显示多个视图

I have multiple linear layout in this layout.The scroll view is working when i am fully scrolled the item, but not in list view.My list view have multiple list items it show only one list item at a time thanks help me.....

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/taskscrollviewid"
    android:layout_width="match_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:scrollbars="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:weightSum="2" >

            <Button
                android:id="@+id/txtdate"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector" />

            <Button
                android:id="@+id/btnTaskTimeid"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector" />
        </LinearLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal" >

            <EditText
                android:id="@+id/txtItem"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/edittextselector"
                android:drawableEnd="@drawable/inbox"
                android:gravity="top|left"
                android:hint="Enter task"
                android:inputType="textMultiLine"
                android:maxLines="5"
                android:minLines="3"
                android:scrollbars="vertical"
                android:singleLine="false" />

            <ImageButton
                android:id="@+id/imagebuttonid"
                android:layout_width="31dp"
                android:layout_height="36dp"
                android:layout_gravity="right|bottom"
                android:background="@drawable/inbox" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:weightSum="2" >

            <Button
                android:id="@+id/btnaddcategoryid"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector"
                android:text="AddCategory" />

            <Button
                android:id="@+id/btnaddseverityid"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector"
                android:text="AddSeverity" />
        </LinearLayout>

        <Button
            android:id="@+id/btnadddb"
            android:layout_width="wrap_content"
            android:layout_height="30px"
            android:layout_gravity="center|center_horizontal"
            android:layout_marginTop="10dp"
            android:background="@drawable/taskbuttonselector"
            android:text="Add This Task" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:weightSum="2" >

            <Button
                android:id="@+id/fillbut"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector"
                android:text="Remain Task" />

            <Button
                android:id="@+id/remainbut"
                android:layout_width="0dip"
                android:layout_height="30px"
                android:layout_weight="1"
                android:background="@drawable/taskbuttonselector"
                android:text="Finish Task" />
        </LinearLayout>

        <ListView
            android:id="@+id/listid"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:clickable="true"
            android:orientation="vertical" >
        </ListView>
    </LinearLayout>

</ScrollView>

解决方案

NEVER put a list view inside a scroll view or vice versa! It says so right in the documentation:

You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.

阅读全文

相关推荐

最新文章