Some Check Box areautoatically Selected While Scrolling Up and Down in ListView

Hi there.

I have one problem that while I am Scroll down/up a custom listview layout then one of item in my custom layout is checkbox which is automatically getting selected in random up/down scroll.

This is my adapter code

[code=java]
public class StudentSearchViewAdapter extends ArrayAdapter<Calendar_Faculty_Model> {

List&lt;Calendar_Faculty_Model&gt; seacrhData; /*
										 * This will store all list of
										 * Student in Search
										 */

Set&lt;String&gt; selectedStudentLsit = new HashSet&lt;String&gt;();

Set&lt;String&gt;  StudentList=new HashSet&lt;String&gt;();

ViewHolder holder;


public Set&lt;String&gt; getStudentList() {
	return StudentList;
}

public Set&lt;String&gt; getSelectedStudentLsit() {
	return selectedStudentLsit;
}



Context context;

LayoutInflater inflator;

int layoutResourceId;

String first_name,last_name,Course,branch,status;



public StudentSearchViewAdapter(Context context, int resource,
		List&lt;Calendar_Faculty_Model&gt; objects) {
	super(context, resource, objects);
	// TODO Auto-generated constructor stub
	this.context = context;
	this.layoutResourceId = resource;
	this.seacrhData = objects;
	
	
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub

	System.out.println("Inside getView()..");

	
	if (convertView == null) {
		
		holder=new ViewHolder();
		
		inflator = ((Activity) context).getLayoutInflater();

		convertView = inflator.inflate(layoutResourceId, null);

		holder.username = (TextView) convertView.findViewById(R.id.cfv_tv_username);
		holder.course = (TextView) convertView.findViewById(R.id.cfv_tv_course);
		holder.userid = (TextView) convertView.findViewById(R.id.cfv_tv_userid);
	    holder.status=(CheckBox)convertView.findViewById(R.id.cfv_chk_status);
        convertView.setTag(holder);
	} 

	holder = (ViewHolder) convertView.getTag();

	first_name = seacrhData.get(position).getFirst_name();
	last_name = seacrhData.get(position).getLast_name();
	final String User_Id = seacrhData.get(position).getUser_id();
	Course = seacrhData.get(position).getCourse();
	branch = seacrhData.get(position).getBranch();
	status=seacrhData.get(position).getStatus();
    holder.username.setText(first_name + " " + last_name);
	holder.userid.setText(User_Id);
	holder.course.setText(Course + " " + branch);
	StudentList.add(User_Id);
	
     if (status.equals("Present")) {
		holder.status.setChecked(true);
		selectedStudentLsit.add(User_Id);
		System.out.println("?&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Alread ySelecteds" + User_Id);
	  }

	
	holder.status.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			// TODO Auto-generated method stub
			
			System.out.println("Inside onCheckedChanged()");
			if(buttonView.isChecked()){
				System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;" + User_Id + "is Selected");
				selectedStudentLsit.add(User_Id);
			}else{
				if(selectedStudentLsit.contains(User_Id)){
					selectedStudentLsit.remove(User_Id);
					System.out.println("Elemment is remover " + User_Id);}
				else
					System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;" + User_Id + " Not availabel in list");
			}
			System.out.println("Exiting onCheckedChanged()");
		}
		
	});
    System.out.println("Exiting getView()");
	return convertView;
}

static class ViewHolder {
	TextView username;
	TextView course;
	TextView userid;
	CheckBox status;
}

}



this is my custom xml layout
[code=java]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/cfv_tv_username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Name" 
        android:textSize="17sp"/>

    <TextView
        android:id="@+id/cfv_tv_userid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/cfv_tv_username"
        android:text="User Id" 
        android:textSize="17sp"/>

    <TextView
        android:id="@+id/cfv_tv_course"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/cfv_tv_userid"
        android:text="Course" 
        android:textSize="17sp"/>

   <CheckBox
        android:id="@+id/cfv_chk_status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/cfv_tv_userid"
        android:layout_alignParentRight="true"
        android:text="CheckBox" />

   

</RelativeLayout>

all thing is work fine that setting listActivity adapter and else
But List Scrolling will sometime change some checkbox to checked?

Where I am wrong?

The adapter recycles its views. What you see is the last state of the row.
Just use
holder.status.setChecked(false);
before the row
if (status.equals(“Present”)) {