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

The Archive Base Latest Questions

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

I have list view [text view and check box controlls] with more data. I

  • 0

I have list view [text view and check box controlls] with more data. I will choose the item from list view and display the selected items in the next activity.
My problem is, for the example if I choose 20th and 25th item in the list view it will display some other items in the next activity. That is list view position is getting changed when scrolling.

i am choosing an item by clicking the check box on the item. in the checkbox.setOnChanged listener i wrote code for which position is selected or not. if i choose 25th item and scroll the list view, the getview method is called and the checkbox.setonChanged method is change the selected position. I print the logcat at last.

My coding format:

public class ListContact extends ListActivity {
  public void onCreate(Bundle icicle){
    .....
    ArrayAdapter<Model> adapter = new MyCustomArrayAdapter(this,getModel());
    setListAdapter(adapter);
  }
 ....
private List<Model> getModel() {
    List<Model> list = new ArrayList<Model>();

Iterator<String> itr = constant.selectname.iterator();
    while (itr.hasNext()) {
        list.add(get(itr.next().toString()));
    }
    return list;
}

private Model get(String s) {
    return new Model(s);
}  

}

MyCustomArrayAdapter.java:

public class MyCustomArrayAdapter extends ArrayAdapter<Model> {

    private final List<Model> list;
    private final Activity context;
    constant con ;
    public MyCustomArrayAdapter(Activity context, List<Model> list) {
        super(context, R.layout.list_layout, list);
        this.context = context;
        this.list = list;
    }

    static class ViewHolder {
        protected TextView text;
        protected CheckBox checkbox;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

//      Log.e("getview", "getview");
        View view = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            view = inflator.inflate(R.layout.list_layout, null);
            final ViewHolder viewHolder = new ViewHolder();
            viewHolder.text = (TextView) view.findViewById(R.id.label);
            viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check);
            viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
//                          con = new constant();
                            Model element = (Model) viewHolder.checkbox.getTag();
                            element.setSelected(buttonView.isChecked());
//                          Log.e("MyCustomArrayAdapter.java", "selectpos array list length"+constant.selectpos.size());
                            if(isChecked==true){
                                Log.e("check box value and position  ", element.getName());
                                Log.e("position", ""+position);
                                con.selectpos.set(position, 1);

                            }
                            else{
                                Log.e("position unselect", ""+position +"---------"+ element.getName());
                                con.selectpos.set(position, 0);
                            }
                        }
                    });
            view.setTag(viewHolder);
            viewHolder.checkbox.setTag(list.get(position));
        } else {
            view = convertView;
            ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position));
        }
        ViewHolder holder = (ViewHolder) view.getTag();
        holder.text.setText(list.get(position).getName());
        holder.checkbox.setChecked(list.get(position).isSelected());
        return view;
    }
}

logcat result:

02-08 10:44:28.142: E/check box value and position(293): AAAA  Qqq 
02-08 10:44:28.142: E/check box value and position(293): Mobile-123
02-08 10:44:28.152: E/position(293): 0

**after scrolling the list view some other item print 0th position unselected and wrong data:**
02-08 10:44:31.962: E/position unselect(293): 0---------F212
02-08 10:44:31.962: E/position unselect(293): Home-232
  • 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-29T08:38:17+00:00Added an answer on May 29, 2026 at 8:38 am

    I solved the problem. i add the

      View view = null;
      convertView = null;  //in the get view and comments the else part of
            if (convertView == null) {
                    }
                    /*else{
                    } */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list view [text view and check box controlls] with more data. I
I have a list view control which at the moment only allows one item
I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I
I have a simple list view with some check boxes in an alert dialog.
I have a checkbox, a drop down list and a text box. I want
I have a list view that is periodically updated (every 60 seconds). It was
Hello i have a list view control, While the form is being loaded i
I have a databound list view and can set all the column widths manually
I have used a list view that uses a grid view in WPF. I

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.