小编kas*_*hey的帖子

CheckedTextView未选中

我想要一个Multiselected (checked) listview.当我选择一个项目时,必须出现绿色复选标记.为此,我使用CheckedTextViews.在ListView从数据库中获取数据.我正在使用SimpleCursorAdapter它.单击按钮后,所选条目(ID)将传递到下一个活动.

我的问题是CheckedTextView没有出现复选标记.但ID将传递给下一个活动.我究竟做错了什么?怎么解决?

selecttest.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

        <Spinner
        android:id="@+id/spinner_select_language"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

        <Button
            style="@style/btn_Font"
            android:id="@+id/selecttest_start"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/spinner_test"
            android:onClick="onClick"
            android:text="@string/selecttest_start" />

        <ListView
            android:id="@+id/lv_lesson"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:fadeScrollbars="false"
            android:choiceMode="multipleChoice"
            android:layout_alignParentLeft="true"
            android:cacheColorHint="#00000000"
            android:layout_below="@+id/selecttest_start" >
        </ListView>

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

dataset_ctv_lesson.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <CheckedTextView
        style="@style/tv_Font"
        android:id="@+id/ctv_lesson"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/none" 
        android:checkMark="@drawable/ctv_state_checker"
        />

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

ctv_state_checker.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_checked="false"
          android:drawable="@drawable/btn_check_buttonless_off" …
Run Code Online (Sandbox Code Playgroud)

android listview checkedtextview simplecursoradapter

5
推荐指数
1
解决办法
4354
查看次数