相关疑难解决方法(0)

Android:将数据从数据库绑定到ListView中的CheckBox?

我正在尝试将数据从我绑定SQLiteDatabaseListView.我现在用的SimpleCursorAdapter是填写我的ListView.不幸的是,这似乎不适用于设置CheckBox的checked属性.

这就是我现在这样做的方式; 而不是更改CheckBox的检查状态,适配器正在填充text参数的值,因此该值显示在CheckBox右侧作为文本.

Java的:

setListAdapter( new SimpleCursorAdapter( this,
      R.layout.mylist,
      data,
      new String[] { Datenbank.DB_STATE, Datenbank.DB_NAME },
      new int[] { R.id.list_checkbox, R.id.list_text }
    ) );
Run Code Online (Sandbox Code Playgroud)

mylist.xml:

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

<CheckBox android:text=""
    android:id="@+id/list_checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="false"
    ></CheckBox>

<TextView android:text=""
    android:id="@+id/list_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ></TextView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

编辑:数据库中的字段当然是boolean类型的,我也尝试将id分配给checked字段以填充值.

checkbox android listview cursor

43
推荐指数
2
解决办法
8万
查看次数

滚动多个ListViews for Android

我完全被这个困扰了.我有三个不同的列表需要在屏幕上显示.列表完全可能会延伸到屏幕的下边缘,所以我需要滚动.

我已经尝试过ScrollView和一个LinearLayout孩子一起使用,然后把我ListViewsLinearView所有ListViews锁都用滚动条固定在一个固定的高度上.使用其他类型的布局意味着不滚动.

有没有人有任何建议,或者我是否需要以编程方式将列表项添加到某些布局并希望最好?

android listview scrollview android-linearlayout

33
推荐指数
3
解决办法
3万
查看次数

如何让我的ListView滚动?

我有一个非常复杂的View构建,作为其中的一部分,我在ScrollView中的LinearLayout内部有一个ListView(还有很多组件,但在这个问题上它们并不重要).

现在整个活动滚动得很好,但ListView的高度有限,当它里面的项目超过高度时,我的屏幕消失了.我试图将ListView放在它自己的ScrollView中,但这不起作用.当我尝试在ListView上滚动时,选择了主ScrollView并且我的屏幕滚动而不是ListView.

我的问题可能听起来很简单,但我无法解决这个问题......是否有可能使ListView可滚动?

相关的XML:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

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

        <ListView android:id="@+id/EndpointList"
                  android:choiceMode="multipleChoice"
                  android:layout_height="175dip"
                  android:layout_width="fill_parent" />

    </LinearLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

android listview scrollable

13
推荐指数
2
解决办法
3万
查看次数

如何在垂直列表视图中制作可水平滚动的项目?

我想在垂直滚动的Listview中使用horizo​​ntall滚动项.

我天真的想法是将listview项的内容放在scrollView中.项目在水平方向上比滚动视图宽,但不高于滚动视图.由于listview是一个普通的垂直滚动列表视图,我认为垂直拖动会在列表中滚动,而水平拖动会在项目中滚动.

但是那没用.列表垂直滚动并正确显示项目,但水平滚动不起作用(没有任何反应).不幸的是,我真的不确定从哪里开始.

请注意,项目应独立于其他项目水平滚动,即横向拖动时整个列表不应向侧面滚动.

作为参考,我希望该列表的行为类似于它在应用程序'Pulse'中的行为,以防您看到它.

android listview scrollview

6
推荐指数
2
解决办法
9615
查看次数