On Scrolling Of listview radio button is automatically changing its state and some are previously checked in android
<p><a href="http://i.stack.imgur.com/KxGId.png" rel="nofollow">it is list of student selected by me</a>      <a href="http://i.stack.imgur.com/hTsAp.png" rel="nofollow">it is list of student already selected when i scroll list</a> in my custom list view when i am running application then radio buttons at bottom are already checked when i am checking upper radio button .how can i set radio button so that its state never change on scrolling list . </p>

<p>Here is my code for studentlist.java </p>

<pre><code>public class studentlist extends AppCompatActivity  {


    private static final String TAG_RESULTS="result";
    private static final String TAG_ID = "id";
    private static final String TAG_ClassDet = "classdetails";
    private static final String TAG_YEAR = "yearof";
    private static final String TAG_BRANCH ="branchof";
    private static final String TAG_SECTION ="sectionof";

    private static String KEY_SUCCESS = "success";
    private static String KEY_ERROR = "error";


    private  ArrayList&lt;HashMap&lt;String, String&gt;&gt; studentattendence,studentstatus;
    ListView listView;
    ArrayAdapter&lt;Model&gt; adapter;
    List&lt;Model&gt; list = new ArrayList&lt;Model&gt;();
    public ArrayList&lt;HashMap&lt;String, String&gt;&gt; personList;
    private static final String KEY_STUDENT = "student";
    private RadioGroup radioGroup;
    private RadioButton radiobtn;
public Button ok;
    private RadioButton radioButton;
    HashMap&lt;String, String&gt; contact,contactstatus;
    private String convertjson;
    private String statusofattendence;


    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.liststudent);




        listView = (ListView) findViewById(R.id.my_list);
studentattendence=new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
studentstatus=new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
        personList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
        Intent getstud = getIntent();
        personList = (ArrayList&lt;HashMap&lt;String, String&gt;&gt;) getstud.getSerializableExtra(KEY_STUDENT);
ok= (Button) findViewById(R.id.ok);

  Toast.makeText(getApplicationContext(), pioGroup.ersonList.get(0).get("enrolment") + "" + personList.get(1).get("enrolment") + "" + personList.get(2).get("enrolment"), Toast.LENGTH_LONG).show();


        adapter = new MyAdapter(this, getModel(personList));
        listView.setAdapter(adapter);

         radioGroup = (RadioGroup) findViewById(R.id.radio);
                          listView.childDrawableStateChanged(radioGroup);






        ////ok button click get status of each radio button and store in hashmap
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int child=listView.getChildCount();
                ArrayList&lt;String&gt; radio=new ArrayList&lt;&gt;();
                View[] vy = new View[1];

                Log.d("child", String.valueOf(child));
for(int i=0;i&lt;child;i++) {
 //   RadioGroup rd = (RadioGroup) listView.getChildAt(i);


   View rgg=listView.getChildAt(i);
    Log.d("radioview",String.valueOf(rgg));
    radioGroup = (RadioGroup) rgg.findViewById(R.id.radio);
   Log.d("radiogroup", String.valueOf(radioGroup));
    int selectedId=radioGroup.getCheckedRadioButtonId();

    radioButton = (RadioButton) rgg.findViewById(selectedId);
    TextView tv= (TextView) rgg.findViewById(R.id.label);
    Log.d("radiobutton and id", selectedId + "" + radioButton);

String status= radioButton.getText().toString();
    Log.d("hello",status);

    String enrol=tv.getText().toString();
    contact = new HashMap&lt;String, String&gt;();
    contact.put("enrollmentnum",enrol);
    Log.d("enum",enrol);
    studentattendence.add(contact);
contactstatus = new HashMap&lt;String, String&gt;();
    contactstatus.put("status",status);
    Log.d("ststuss",status);
    studentstatus.add(contactstatus);

}

///here converting arraylist in to json string
                convertjson = new Gson().toJson(studentattendence);
                statusofattendence=new Gson().toJson(studentstatus);
    Toast.makeText(getApplicationContext(),""+convertjson+""+statusofattendence,Toast.LENGTH_LONG).show();
                NetAsync(v, convertjson,statusofattendence);
            }
        });

    }


    private List&lt;Model&gt; getModel(ArrayList&lt;HashMap&lt;String, String&gt;&gt; personList) {
        for (int i = 0; i &lt; personList.size(); i++) {
            String enrolment = personList.get(i).get("enrolment");
            list.add(new Model(enrolment));

        }

        return list;
    }
    ////now we will send taked attendence to webservice
    private class NetCheck extends AsyncTask&lt;String,String,Boolean&gt;
    {
public final String convertjson,statusofattendence;
        private ProgressDialog nDialog;

        public NetCheck(String convertjson,String statusofattendence) {
            this.convertjson=convertjson;
            this.statusofattendence=statusofattendence;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            nDialog = new ProgressDialog(studentlist.this);
            nDialog.setMessage("Loading..");
            nDialog.setTitle("Checking Network");
            nDialog.setIndeterminate(false);
            nDialog.setCancelable(true);
            nDialog.show();
        }

        @Override
        protected Boolean doInBackground(String... args) {



/**
 * Gets current device state and checks for working internet connection by trying Google.
 **/
            /*
            ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo netInfo = cm.getActiveNetworkInfo();
            if (netInfo != null &amp;&amp; netInfo.isConnected()) {
                try {
                    URL url = new URL("http://www.google.com");
                    HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
                    urlc.setConnectTimeout(3000);
                    urlc.connect();
                    if (urlc.getResponseCode() == 200) {
                        return true;
                    }
                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }*/
            // return false;
            return true;
        }

        @Override
        protected void onPostExecute(Boolean th) {

            if (th == true) {
                nDialog.dismiss();
                new ProcessRegister().execute();
            } else {
                nDialog.dismiss();

            }
        }
    }

    private class ProcessRegister extends AsyncTask&lt;String, String, JSONObject&gt; {


        private ProgressDialog pDialog;

        String forgotpassword;
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            pDialog = new ProgressDialog(studentlist.this);
            pDialog.setTitle("Contacting Servers");
            pDialog.setMessage("Getting Data ...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        @Override
        protected JSONObject doInBackground(String... args) {

TeacherFunctions userFunction = new TeacherFunctions();
            Log.d("convertjson",convertjson);
                        Log.d("convertjson",statusofattendence);
            JSONObject json = userFunction.addAttendence(convertjson,statusofattendence);

            return json;
        }


        @Override
        protected void onPostExecute(JSONObject json) {
            /**
             * Checks if the Password Change Process is sucesss
             **/
            try {
                if (json.getString(KEY_SUCCESS) != null) {

                    String res = json.getString(KEY_SUCCESS);
                    String red = json.getString(KEY_ERROR);


                    if(Integer.parseInt(res) == 1){
                        pDialog.dismiss();

                        Toast.makeText(getApplicationContext(),"students Attendence Uploaded successfully"+json.getString("user"),Toast.LENGTH_LONG).show();


                    }
                    else if (Integer.parseInt(red) == 2)
                    {    pDialog.dismiss();
                    }
                    else {
                        pDialog.dismiss();

                    }




                }}
            catch (JSONException e) {
                e.printStackTrace();

                pDialog.dismiss();

                Toast.makeText(getApplicationContext()," not Uploaded successfully"+e,Toast.LENGTH_LONG).show();

            }
        }}
    public void NetAsync(View view, String convertjson,String statusofattendence){
        new NetCheck(convertjson,statusofattendence).execute();
    }
}
</code></pre>

<p>Code for model.java</p>

<pre><code>public class Model {

    private String name;
    private boolean selected;

    public Model(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }
} 
</code></pre>

<p>code for MyAdapter.java</p>

<pre><code>public class MyAdapter extends ArrayAdapter&lt;Model&gt; {

    private final List&lt;Model&gt; list;
    private final Activity context;
    boolean checkAll_flag = false;
    boolean checkItem_flag = false;

    public MyAdapter(Activity context, List&lt;Model&gt; list) {
        super(context, R.layout.row, list);
        this.context = context;
        this.list = list;
    }

    static class ViewHolder {
        protected TextView text;
        protected RadioButton radiobox;
    }

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

        ViewHolder viewHolder = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            convertView = inflator.inflate(R.layout.row, null);
            viewHolder = new ViewHolder();
            viewHolder.text = (TextView) convertView.findViewById(R.id.label);
            viewHolder.radiobox = (RadioButton) convertView.findViewById(R.id.radio1);
            viewHolder.radiobox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int getPosition = (Integer) buttonView.getTag();  // Here we get the position that we have set for the checkbox using setTag.
                    list.get(getPosition).setSelected(buttonView.isChecked()); // Set the value of checkbox to maintain its state.
                }
            });
            convertView.setTag(viewHolder);
            convertView.setTag(R.id.label, viewHolder.text);
            convertView.setTag(R.id.radio1, viewHolder.radiobox);
            } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.radiobox.setTag(position); // This line is important.

        viewHolder.text.setText(list.get(position).getName());
        viewHolder.radiobox.setChecked(list.get(position).isSelected());

        return convertView;
    }
}
</code></pre>