Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在布局中使用更多的ListView来克服此问题_Java_Android_Listview - Fatal编程技术网

Java 如何在布局中使用更多的ListView来克服此问题

Java 如何在布局中使用更多的ListView来克服此问题,java,android,listview,Java,Android,Listview,我在布局中使用了4个listview,如果使用scrollview,则无法滚动到我的listview。如果删除xml中的scrollview,则最后一个列表将被隐藏。如何克服这个问题 我的代码如下: <?xml version="1.0" encoding="utf-8"?> <ScrollView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="f

我在布局中使用了4个listview,如果使用scrollview,则无法滚动到我的listview。如果删除xml中的scrollview,则最后一个列表将被隐藏。如何克服这个问题

我的代码如下:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="42.0dip">
    <Button android:textSize="23.0dip" android:onClick="newtodo_Click" android:textStyle="bold" android:textColor="#ffffffff" android:gravity="center" android:id="@id/btnNewTodo" android:background="@drawable/new_todo" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<TextView android:textColor="#000000" android:layout_height="wrap_content" android:background="#FF0000" android:layout_width="match_parent" android:text="High Priority" android:id="@+id/textView1"></TextView>
<ListView android:id="@+id/lvhigh" android:cacheColorHint="#00000000" android:background="#000000" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#ffff01" android:textColor="#000000" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Medium Priority" android:id="@+id/textView2"></TextView>
<ListView android:id="@+id/lvmed" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#00ff01" android:textColor="#000000"  android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Low Priority" android:id="@+id/textView3"></TextView>
<ListView android:id="@+id/lvlow" android:layout_width="match_parent" android:layout_height="175px"></ListView>
<TextView android:background="#cccccc" android:textColor="#000000" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Incomplete Tasks" android:id="@+id/textView4"></TextView>
<ListView android:id="@+id/lvinc" android:layout_width="match_parent" android:layout_height="175px"></ListView>

</LinearLayout>
</ScrollView>


非常感谢并提前感谢您的帮助…

在您的版面中有textview,在该listview之后还有listview,所以为什么不使用可扩展listview。它将帮助您解决问题

下面是可扩展列表视图的示例


在您的布局中有textview,在该listview之后是listview,所以为什么不使用expandable listview。它将帮助您解决问题

下面是可扩展列表视图的示例


要克服这个问题,请尝试重新分解UI,使其不在另一个可滚动对象中包含多个可滚动对象。这将是不可靠的,并将产生意外的结果(如您所发现的)


正如100RABH所说,这通常是一个糟糕的设计。通常,应用程序会向用户显示某种类型的列表。对于2-5英寸(平板电脑约10英寸)的屏幕,四个列表太多了。

要克服这个问题,请尝试重新分解UI,使其不在另一个可滚动对象中包含多个可滚动对象。这将是不可靠的,并将产生意外的结果(如您所发现的)


正如100RABH所说,这通常是一个糟糕的设计。通常,应用程序会向用户显示某种类型的列表。对于2-5英寸(平板电脑约10英寸)的屏幕,四个列表太多。

请使用将listview设置为非滚动容器

ls_edu.setScrollContainer(false);

滚动列表视图可能会有所帮助。

请使用将列表视图设置为非滚动容器

ls_edu.setScrollContainer(false);

滚动列表视图可能会有所帮助。

一个简单的解决方法是

  • 删除
    ScrollView
  • 将所有
    列表视图的高度设置为0
  • 将所有子级的
    layout\u weight
    属性设置为1

  • 一个简单的解决方法是

  • 删除
    ScrollView
  • 将所有
    列表视图的高度设置为0
  • 将所有子级的
    layout\u weight
    属性设置为1

  • 也许您不应该对每个listview的高度使用wrap_内容。更小的东西还可以吗?我认为这只是一个糟糕的设计,你的应用程序中应该只有一个列表视图,最多两个,但有4个是疯狂的。我不确定你的应用程序是否真的能通过这样的界面向用户传达很多信息。顺便说一句,如果scrollView中有一个listview,它将不起作用。这是以像素/dp为单位给出值的正确方法吗?也许你不应该对每个listview的高度使用wrap_内容。更小的东西还可以吗?我认为这只是一个糟糕的设计,你的应用程序中应该只有一个列表视图,最多两个,但有4个是疯狂的。我不确定你的应用程序是否真的能通过这样的界面向用户传达很多信息。顺便说一句,如果scrollView中有一个listview,它将无法工作。而不是包装内容,这是以像素/dp为单位给出值的正确方式吗?因为我是android新手,我正在搜索最佳方式。。。是否有任何引用链接可以使用可扩展列表视图?因为我是android新手,我正在搜索最佳方式。。。是否有使用可扩展列表视图的引用链接?