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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:48+00:00 2026-05-23T11:02:48+00:00

I have an activity which inherits ListActivity, and shows a list populate via an

  • 0

I have an activity which inherits ListActivity, and shows a list populate via an XML layout and a custom adapter class. It all renders fine, and as expected. The row XML includes in it a checkbox.

Now, what’s weird is that the checkboxes seem to be linked every so many rows. That is, if I check the checkbox in row 0, then it also checks the checkboxes in rows 8, 18, 28, 38, 48, etc.

Why would this be, and how can I fix it?

If it is pertinent, i am reusing the view passed into my adapter when it is available. It does also seem that when I scroll one of the checked ones to the top of the screen, the next one to be checked is the second one off the bottom of the screen.

Below is my getView code:

public View getView(int position, View convertView, ViewGroup parent) {     
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater)
            mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.contacts_row, null);
    }

    cb.GroupMembership.moveToPosition(position);
    long cid = cb.GroupMembership.getLong(0);
    String clk = cb.GroupMembership.getString(1);
    String cnm = cb.GroupMembership.getString(2);
    long pid = cb.GroupMembership.getLong(3);

    ImageView bdg = (ImageView) v.findViewById(R.id.contactBadge);
    Uri pic = GroupsLib.getContactPhotoUri(pid);
    if (pic == null) {
        bdg.setImageResource(R.drawable.contactg);
    } else {
        bdg.setImageURI(pic);
    }

    ((TextView) v.findViewById(R.id.contactName)).setText(cnm);

    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-23T11:02:48+00:00Added an answer on May 23, 2026 at 11:02 am

    When you reuse your view you should actually set the state of all controls in it (so basically clean-up). Precisely because it is reused.

    Usually it would look like (in adapter):

    public View getView (int position, View convertView, ViewGroup parent) {
        SomeObject obj = getDataFromYourModel(position);
        if (convertView == null) { 
            convertView = ....; //inflate view here
        } 
    
        setMyViewParameters(obj,convertView);
    }
    
    public void setMyViewParameters(SomeObject obj, View view) {
        CheckBox cb = (CheckBox) view.findViewById(R.id.checkbox_id);
    
        cb.setChecked(obj.isChecked);
        //other initialisation
    }
    

    This way, you always reset the values when the view is reused.

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

Sidebar

Related Questions

I have an activity which shows some List entries. When I click on a
i have a activity which extends ListActivity. The Layout contains some generic widget an
I have an Activity which already extends from my own custom Activtiy class. How
I have an Activity which shows a welcome message if started for the first
I have an activity which shows an image (ViewCollection.java). I want to only create
Well I have an activity which contains nothing but a relative layout with brown
I have activity_main which is default layout in my activity, there i have framelayout
I have an activity which is used for editing some object. Currently its layout
I have an Activity which is an OpenGL view. I also have an xml
I have main activity which call other object, for example GPS class. This GPS

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.