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

  • Home
  • SEARCH
  • 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 6382213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:29:38+00:00 2026-05-25T02:29:38+00:00

I am not sure if its just me or something else is wrong in

  • 0

I am not sure if its just me or something else is wrong in my code. I am populating all the phone contacts in a custom listview and all is fine until its populated. The custom listview has a checkbox so that multiple items can be selected. The problem is when I have say 30 contacts loaded in the listview and I select the first contact and I scroll down I see that 11th and 21st contact is also selected. I am not sure why this is happening any information in this unusual issue would be helpful.

Here’s the xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" 
android:layout_height="match_parent">
    <ListView android:id="@android:id/list"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:drawSelectorOnTop="false"   
        android:choiceMode="multipleChoice"/>
    <TextView android:id="@+id/empty"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:text="@string/main_no_contacts"
        android:textColor="@color/white"/>
    </LinearLayout>

The custom layout is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/rlContactListRowMain" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:padding="5dp">
<ImageView  android:id="@+id/ivContactIconRow" 
            android:src="@drawable/droid_small" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"/>
<RelativeLayout android:id="@+id/rlContactListRowChild"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/ivContactIconRow" 
                android:layout_alignTop="@+id/ivContactIconRow">
                <TextView   android:text="Vikram Ramanathan"
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content" 
                            android:id="@+id/tvRowContactName" 
                            android:paddingLeft="10dip"
                            android:textColor="@color/white"/>
                <TextView   android:text="Phone Numbers: " 
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content" 
                            android:paddingLeft="10dip" 
                            android:id="@+id/tvRowContactPhone"
                            android:layout_below="@+id/tvRowContactName"
                            android:textColor="@color/white"/>                                                                                                                                  
</RelativeLayout>
<CheckBox   android:id="@+id/chkSelectContact" 
            android:layout_height="wrap_content" 
            android:text="" 
            android:layout_width="wrap_content" 
            android:layout_alignParentRight="true"></CheckBox>                          
    </RelativeLayout>

The java code is

    super.onCreate(savedInstanceState);
    setContentView(R.layout.listcontacts);
    phoneContactList = new ArrayList<PhoneContactInfo>();
    this.m_adapter = new PhoneContactListAdapter(this, R.layout.listcontacts_row, phoneContactList);
    setListAdapter(this.m_adapter);

The adapter code is

View v = convertView;
    if (v == null) 
    {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.listcontacts_row, null);
    }

    PhoneContactInfo phoneContactInfo = phoneContacts.get(position);

    if (phoneContactInfo != null) 
    {
        TextView tvContactName = (TextView) v.findViewById(R.id.tvRowContactName);

        if (tvContactName != null)
        {
            tvContactName.setText(phoneContactInfo.getContactName());
        }

        TextView tvContactNumber = (TextView) v.findViewById(R.id.tvRowContactPhone);

        if (tvContactNumber != null)
        {
            tvContactNumber.setText(phoneContactInfo.getContactNumber());   
        }
    }
    v.setTag(phoneContactInfo);
    phoneContactInfo = null;
    return v;
  • 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-05-25T02:29:38+00:00Added an answer on May 25, 2026 at 2:29 am

    I think the problem is that when you populate items you update TextViews and you don’t update CheckBox. Your layout for list item is reused and that’s why the next item has CheckBox checked. Try saving CheckBox state for every in a list or in your custom class and save it or load it from there.

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

Sidebar

Related Questions

I'm not sure if it's just me, but whenever I open .txt files in
Ok so this is alittle bit obscure and I'm not sure its the best
Im not sure that its possible to do what I want to accomplish. I
I am thinking on the following approach but not sure if its the best
I am building a C# client for a CGI service (not sure what its
This is really stumping me today. I'm sure its not that hard, but I
I'm trying to get this expression to work, I'm pretty sure its not the
Not quite sure how to troubleshoot this. I'm maintaining an ASP site, its mostly
I start GVIM in not-maximized window mode and split its window horizontally making sure
This is just kind of general question, steming from something else. Say you want

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.