两个列表视图和放大器;滚动型 [英] Two ListViews & ScrollView

查看:88
本文介绍了两个列表视图和放大器;滚动型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是如此接近在这里,我已经尝试了很多东西,但无法得到它的工作。我有两个列表视图这里。我想是每个列表视图,以显示其全部内容。我不希望列表视图滚动。我想保存的列表视图滚动滚动视图。最近我一直能够得到它(这是错误的),更是让每一个列表视图可滚动。这意味着,每个列表视图仅示出样1 1/2细胞。我认为这将是一个污垢简单的任务,但Android有一些古怪的事情怎么回事。

所以,再一次,每个列表视图中显示了它的全部内容,即使这些内容的高度去通过屏幕。然后,所有我需要做的就是向下滚动到看到第二个列表视图,显示了它的全部内容。

 < XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_height =FILL_PARENT
机器人:layout_width =WRAP_CONTENT
机器人:方向=垂直
机器人:fillViewport =真正的>
<的LinearLayout
机器人:layout_height =FILL_PARENT
机器人:layout_width =WRAP_CONTENT
机器人:方向=垂直
机器人:fillViewport =真正的>
<的LinearLayout
机器人:layout_weight =10
机器人:方向=垂直
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =FILL_PARENT>
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:后台=#CCCCCC
机器人:文本=@字符串/ alerts_top_title
机器人:重力=中心
机器人:文字颜色=#000000
机器人:layout_centerVertical =真
机器人:layout_centerHorizo​​ntal =真正的>
< / TextView的>
<的ListView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID / cameraListAlerts>
< / ListView控件>
< / LinearLayout中>
<的LinearLayout
机器人:layout_weight =10
机器人:方向=垂直
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =FILL_PARENT>
<的TextView
机器人:重力=中心
机器人:layout_centerVertical =真
机器人:layout_centerHorizo​​ntal =真
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:后台=#CCCCCC
机器人:文字颜色=#000000
机器人:文本=@字符串/ alerts_bottom_title>
< / TextView的>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =8DP>
< / LinearLayout中>
<按钮
机器人:ID =@ + ID / addRecipient
机器人:layout_height =50dp
机器人:layout_width =FILL_PARENT
机器人:layout_centerHorizo​​ntal =真
机器人:文本=@字符串/ addRecipient/>

<的ListView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID / recipientListAlerts>
< / ListView控件>
< / LinearLayout中>
< / LinearLayout中>
< /滚动型>
 

解决方案

你会花更多的时间和精力去得到这个工作,如果它确实。 的ListView 取值存在是为了处理那些需要太多的资源在同一时间被抽长的列表。他们回收的行视图,当你通过它们滚动以允许瞬间负荷。你试图沟的功能,从而使您的使用的ListView 基本上是没有意义的。

填充的LinearLayout 编程也没什么大不了的。你有你的行的XML文件?当你在阵列或,而遍历光标运行一个非常简单的循环它充气每个新行,结合数据,并将其添加到您的的LinearLayout

完成。没有滚动条问题......这一切都在滚动型处理像它应该的。

I'm so close here and I've tried many things but cannot get it to work. I have two listviews here. What I want is for each listview to show its ENTIRE content. I don't want the listviews scrollable. I want the Scrollview that holds the listviews scrollable. The closest i've been able to get it (which is wrong) is so that each listview is scrollable. This means that each listview only shows like 1 1/2 cells. I would think this would be a dirt simple task but Android has some quirky things going on.

So again, each list view shows its entire content, even if that content height goes past the screen. Then all I have to do is scroll down to see the second list view which shows its entire content.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout 
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:text="@string/alerts_top_title"
android:gravity="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<ListView 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cameraListAlerts" >
</ListView>
</LinearLayout>
<LinearLayout 
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:textColor="#000000"
android:text="@string/alerts_bottom_title">
</TextView>
<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="8dp">
</LinearLayout>
<Button
android:id="@+id/addRecipient"
android:layout_height="50dp"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:text="@string/addRecipient"/>

<ListView 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/recipientListAlerts" >
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>

解决方案

You're going to spend far more time and energy trying to get this to work if it ever does. ListViews exist to handle long lists that require too many resources to be drawn at one time. They recycle the row Views when you scroll through them to allow for a snappy load. You're trying to ditch that functionality, thereby making your use of the ListView essentially pointless.

Populating a LinearLayout programmatically is no big deal at all. Do you have an XML file for your rows? Inflate it for each new row as you run an extremely simple for loop through your Array or while loop through your Cursor, binding the data, and adding it to your LinearLayout.

Done. No scrolling issues... it's all handled by the ScrollView like it should be.

这篇关于两个列表视图和放大器;滚动型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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