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 8023157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:29:24+00:00 2026-06-04T22:29:24+00:00

I use a listview with multiple choice and I override the search method inside.

  • 0

I use a listview with multiple choice and I override the search method inside. I have a problem with the items in that during scrolling the position of items changed. The problem comes from the layout, I think, because when the layout includes only the listview, it works correctly. But, when I use the layout below, the positions of the items checked during scrolling get changed.

Can anyone help with that please?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/button1" />


    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Button" />

    <ListView
        android:id="@+id/MyListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText1" />

</RelativeLayout>
  • 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-04T22:29:25+00:00Added an answer on June 4, 2026 at 10:29 pm

    You need to set up an object in your adapter to keep track of the state of the checkboxes. You haven’t shown your adapter code so I’ll just pull an example from some of my code (this is using a cursor, it can be adapted to an ArrayAdapter)

    In the custom adapter set an array:

    private Cursor c; 
    public static int[] checked; 
    

    In your constructor set your cursor to the local var and call a method:

    CursorAdapter_EditText.c = c; 
    initializeChecked(); 
    

    The method (using 0 = not checked):

    public static void initializeChecked() { 
        checked = new int[c.getCount()]; 
        int i = 0; 
        while (i < c.getCount()) { 
            checked[i] = 0; 
            i++; 
        } 
    } 
    

    In your getView use the array to set the checkbox state:

    checkBox = (CheckBox) view.findViewById(R.id.CheckBox); 
    if (checked(position) == 0) { 
        checkBox.setChecked(false); 
    } else { 
        checkBox.setChecked(true); 
    }  
    

    You’ll need to add code in checkBox.setOnCheckedChangeListener also to change the state in the array when you change the state of the checkbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview that needs to be multiple choice (i.e each list item
I have a listview with 200 items. I use a custom view for each
My problem is that I don't know whether I should use multiple list view
I would like to create a listview that allows multiple choice. The typical solutions
I have a listView that is being updated from multiple threads, with the threads
I use ListView to populate my Menu and Price. I have 2 ListView s
I want to use my own image of arrow for items in listview. Where
I have an xml layout which I use for each row in my listview:
I have an ArrayList of items that are linked to a custom Adapter. The
I have a multiple-selection enabled QListView with an Item delegate (QStyledItemDelegate) I use for

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.