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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:05:43+00:00 2026-06-04T04:05:43+00:00

in my app i load the contacts in a listview. i have the listview

  • 0

in my app i load the contacts in a listview. i have the listview with image,text and a checkbox and implemented by cursor adapter. my problem is when i scroll the listview up / down its position is changed. that is if choose(tick the checkbox) the position 1,3,4,2 and scroll down and up the ticked position is randomly changed. i have spend more time to find out the solution but i could not get it. please help me.

my code ex for adapter:

    public class ContactsListAdapter extends CursorAdapter {

    ContentResolver cr;
    private final LayoutInflater mInflater;
    private Context mContext;

    @SuppressWarnings("unchecked")
    public ContactsListAdapter(Context context, Cursor c,ArrayList<ContactPhoneInfo> selected) {
        super(context, c, true);
        this.checkedContacts = (ArrayList<ContactPhoneInfo>) selected.clone();
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
    }

    public void bindView(View view,Context context_bind, Cursor cursor)
    {   
        final LinearLayout linear = (LinearLayout) view.findViewById(R.id.contacts_linearLayout1);
        final TextView contactEntryText = (TextView) view.findViewById(R.id.contacts_txtViewContactName);
        final CheckBox chkContact = (CheckBox) view.findViewById(R.id.contacts_chkContact);
        final TextView textCaption = (TextView) view.findViewById(R.id.contacts_layoutCaption);
        final ImageView photoView = (ImageView)view.findViewById(R.id.contacts_imgViewcontact);

        ContentResolver cr = context_bind.getContentResolver();
            .......

        int id = Integer.parseInt(cursor.getString(0));
        final String name = cursor.getString(1);

        contactEntryText.setText(name);
            .......
        view.setClickable(true);
        view.setFocusable(true);

        view.setOnClickListener(new OnClickListener() {
            public void onClick(View v) 
            {
                chkContact.setChecked(!chkContact.isChecked());
            }
        });

        chkContact.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                .buttonView.........
            }
        });
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        final View view = mInflater.inflate(R.layout.contacts_listitem, parent,
                false);
        return view;
    }
}

the calling class coding:

        contactsListAdapter = new ContactsListAdapter(this,app.loadContactCursor(""),checkedContacts);
    setListAdapter(contactsListAdapter);
  • 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-04T04:05:44+00:00Added an answer on June 4, 2026 at 4:05 am

    i have solved my problem by call the setOnCheckedChangeListener method before calling setChecked

        chkContact.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                .buttonView.........
            }
        });
    

    after that

    chkContact.setChecked(!chkContact.isChecked());
    

    i refer the following stack over flow question:

    Android listview with checkbox problem

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

Sidebar

Related Questions

My app has to load an image from a http server and displaying it
I'm facing the following problem : my app has to load some web-content and
Say I have a www.foo.com domain which is setup to load my app on
In my app I load some webpages in a 480*320(landscape) UIWebView. But the text
I have a table view. I want my app to work like the Contacts
I am building an app that requres me to load all the contacts in
in my app i am listing contacts in a listview. no of contacts is
I have a Python/Django app that will require database load balancing at some point
In my app i load a weburl in safari when a button is clicked.
The silverlight app wont load in any browser. The outline is there when highlight

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.