安卓:滚动preferences窗口自定义列表视图自定义、视图、窗口、列表

2023-09-04 23:25:39 作者:嗜血、深蓝色

我有与被填充从XML文件preferences,那么另一个的ListView得到由数据填充在我的数据库,然后一个TextView和EditText上一个ListView的活动。

I have an activity with a listview that gets populated with preferences from an xml file, then another listview that gets populated by data in my database, then a textview and a edittext.

我想在屏幕上的每一个元素(包括所有的列表视图)采取充分的高度,整个屏幕会滚动的,但我不知道如何做到这一点!

I want every element (including all the list views) on the screen to take their full height, and the entire screen be scrollable, but I cannot figure out how to do this!

下面是我的xml:

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

    <LinearLayout
        android:id="@+id/llContainer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/llPreferences"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <ListView
                android:id="@android:id/list"
                android:layout_width="fill_parent"
                    android:layout_height="wrap_content">
            </ListView>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llPlaces"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:weightSum="1" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView"
                android:textAppearance="?android:attr/textAppearanceLarge" >
            </TextView>

            <ListView
                android:id="@+id/lstPlaces"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
            </ListView>

            <LinearLayout
                android:id="@+id/llAddNewPlace"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <EditText
                    android:id="@+id/txtNewPlaceName"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" >
                </EditText>

                <Button
                    android:id="@+id/btnAddNewPlace"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Add New" >
                </Button>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

</ScrollView>

这是为什么不执行,因为我想和所期望的任何想法?

Any ideas why this is not performing as I want and would expect?

谢谢, 最大。

推荐答案

Similer问题与解决方案,这个THEAD:

Similer problem with solution on this thead:

Android的滚动型布局问题

不幸的是,它看起来像你不能有一个scrolllayout列表视图。

Unfortunatly it looks like you cannot have a listview in a scrolllayout.

谁的人有兴趣,看起来像一个潜在的解决方法可以在这里找到,现在无论是还是将来:

For people who are interested, looks like a potential workaround could be found here either now or in the future:

ListView在滚动型潜在的解决方法

 
精彩推荐
图片推荐