Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:53:33+00:00 2026-06-16T00:53:33+00:00

I want a Multiselected (checked) listview . When I select an item then the

  • 0

I want a Multiselected (checked) listview. When I select an item then the green check mark must appear. For this I use CheckedTextViews.
The ListView gets the data from the database. I’m using a SimpleCursorAdapter for that.
When you click on the button then the selected entries(IDs) will be passed to the next activity.

My problem is that the check marks of the CheckedTextView does not appear. But the IDs will be passed to the next activity.
What am I doing wrong? How to fix it?

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>

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>

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" />
    <item android:state_checked="true"
          android:drawable="@drawable/btn_check_buttonless_on" />

</selector>

SelectTestActivity.java

public class SelectTestActivity 
extends Activity
implements OnItemSelectedListener 
{
    Database db;
    SimpleCursorAdapter adaptercursor, lv_adaptercursor;
    ListView lv_lesson;

    // Arraylist for checked item in the lesson view
    ArrayList<String> checkedlessons = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.selecttest);

        // Create Database
        db = new Database(this);

        // Drop-Down-Menu to select a language
        Spinner spinner_language = (Spinner) findViewById(R.id.spinner_select_language);
        spinner_language.setOnItemSelectedListener(this);

        Cursor cursor = db.createListViewCursor();

        String[] displaycolumn = new String[]{"language"};
        int[] displayview = new int[] {R.id.tv_language};

        adaptercursor = new SimpleCursorAdapter(this, R.layout.datasetlanguage, cursor, displaycolumn, displayview, 0);
        spinner_language.setAdapter(adaptercursor);

        // ListView to select a lesson
        lv_lesson = (ListView) findViewById(R.id.lv_lesson);

        cursor = db.createListViewLessonCursor(getSelectedItemIDFromSpinnerLanguage());

        displaycolumn = new String[]{"lesson"};
        int[] displayview2 = new int[] {R.id.ctv_lesson};

        lv_adaptercursor = new SimpleCursorAdapter(this, R.layout.dataset_ctv_lesson, cursor, displaycolumn, displayview2, 0);
        lv_lesson.setAdapter(lv_adaptercursor);

        lv_lesson.setOnItemClickListener(new ListView.OnItemClickListener() 
        {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
            {
                if (!checkedlessons.contains(Long.toString(id)))
                {
                    checkedlessons.add(Long.toString(id));

                    // checked textview
                    lv_lesson.setItemChecked(position, true);
                }
                else 
                {
                    checkedlessons.remove(Long.toString(id));

                    // unchecked textview
                    lv_lesson.setItemChecked(position, false);      
                }
            }
        });

        // Close the database
        db.close();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:53:34+00:00Added an answer on June 16, 2026 at 12:53 am
    1. Try to remove the style of your CheckedTextView, i think some values in your style affect the appearance.
    2. Remove the RelativeLayout in dataset_ctv_lesson.xml, and you do not need to change the check state on item clicked. ListView could maintain the check state by itself. Use ListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE) to enable multi-select mode, and use ListView.getCheckedItemPositions() to get the checked row positions.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my function to check which checkboxs are checked. function updateTagChecked() { var
I want to do like this: SELECT * FROM `langCategories` ORDER BY `name` ASC
I use this library (http://labs.abeautifulsite.net/archived/jquery-multiSelect/demo/) for creating a multiple-select dropdown. I want to update
Want the function to sort the table by HP but if duplicate HPs then
I have a multiselect listbox and before submitting the form i want to check
I want the ability to auto stretch the listview control column when the form
i am using the following multiselect box to take input from users, this then
I have a form like this: <form action=/cgi-bin/cgi_info.py method=POST> <select id=faults class=multiselect multiple=multiple name=faults[]>
I want to use the MultiSelect from 3.3 in Ext JS 4, as described
I want to Select First element of drop down automatically when page load occur

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.