Issue with checkbox checked
<p>i am use <a href="http://www.vogella.com/articles/AndroidListView/article.html#listadvanced_interactive" rel="nofollow">this</a> for setting checkbox in listview i have follow all step as per given tutorial, but there are some critical issue with output, is that when i am select first checkbox and scroll down it will change selected item and automatically appear 3rd.</p>

<p>so i think there are something wrong with getview. so please help me out this ....</p>

<p>here is my code ::</p>

<pre><code>package com.AppFavorits;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import android.app.ListActivity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.RatingBar;

public class Favorites extends ListActivity {
    protected static final String TAG = "Favorites";
    CommentsDataSource datasource;
    ListView lstFavrowlistv;
    ArrayList alAppName;
    float[] rate;
    boolean[] bSelected;
    ArrayList&lt;Comment&gt; alPackagenm;
    Drawable[] alIcon;
    ViewHolder holder;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onResume() {
        super.onResume();
        datasource = new CommentsDataSource(this);
        datasource.open();

        alAppName = datasource.getAllComments();
        alPackagenm = datasource.getAllPackage();

        Log.i(TAG, "values &gt;&gt;&gt;" + alAppName);
        Log.i(TAG, "values &gt;&gt;&gt;" + alPackagenm);
        int inc = 0;
        alIcon = new Drawable[200];
        for (int i = 0; i &lt; alPackagenm.size(); i++) {
            Log.i(TAG, "Appname &gt;&gt;&gt;" + GetAllApp.lstpinfo.get(i).pname);
            for (int j = 0; j &lt; GetAllApp.lstpinfo.size(); j++) {
                if (alPackagenm
                        .get(i)
                        .toString()
                        .equalsIgnoreCase(
                                GetAllApp.lstpinfo.get(j).pname.toString())) {
                    alIcon[inc] = GetAllApp.lstpinfo.get(j).icon;
                    Log.i("TAG", "sqlPackagename"
                            + alPackagenm.get(i).toString());
                    Log.i("TAG", "from getAllapp"
                            + GetAllApp.lstpinfo.get(j).pname.toString());
                    inc++;
                }

            }
        }

        ArrayList&lt;RowModel&gt; list = new ArrayList&lt;RowModel&gt;();
        ArrayList&lt;Model&gt; Mlist = new ArrayList&lt;Model&gt;();
        rate = new float[alAppName.size()];
        bSelected = new boolean[alAppName.size()];
        Iterator itr = alAppName.iterator();
        String strVal = null;
        while (itr.hasNext()) {
            strVal += itr.next().toString() + ",";

        }

        int lastIndex = strVal.lastIndexOf(",");
        strVal = strVal.substring(0, lastIndex);
        System.out.println("Output String is : " + strVal);
        String strAr[] = strVal.split(",");

        for (int i = 0; i &lt; strAr.length; i++) {
            System.out.println("strAr[" + i + "] " + strAr[i]);
        }

        for (String s : strAr) {
            list.add(new RowModel(s));
        }
        for (String s : strAr) {
            Mlist.add(new Model(s));
        }
        setListAdapter(new RatingAdapter(list, Mlist));
        datasource.close();
    }

    class RowModel {
        String label;
        float rating = 0.0f;

        RowModel(String label) {
            this.label = label;
        }

        public String toString() {
            if (rating &gt;= 3.0) {
                return (label.toUpperCase());
            }

            return (label);
        }
    }

    private RowModel getModel(int position) {
        return (((RatingAdapter) getListAdapter()).getItem(position));

    }

    class RatingAdapter extends ArrayAdapter&lt;RowModel&gt; {
        private ArrayList&lt;Model&gt; mlist;

        RatingAdapter(ArrayList&lt;RowModel&gt; list, ArrayList&lt;Model&gt; mlist) {
            super(Favorites.this, R.layout.outbox_list_item,
                    R.id.txvxFavrowiconappname, list);
            this.mlist = mlist;
        }

        public View getView(final int position, View convertView,
                ViewGroup parent) {
            View row = super.getView(position, convertView, parent);
            holder = (ViewHolder) row.getTag();
            if (holder == null) {
                holder = new ViewHolder(row);
                row.setTag(holder);

                RatingBar.OnRatingBarChangeListener l = new RatingBar.OnRatingBarChangeListener() {
                    public void onRatingChanged(RatingBar ratingBar,
                            float rating, boolean fromTouch) {
                        Integer myPosition = (Integer) ratingBar.getTag();
                        RowModel model = getModel(myPosition);

                        model.rating = rating;
                        rate[position] = rating;

                    }
                };
                holder.chkbxFavrowsel
                        .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                            @Override
                            public void onCheckedChanged(
                                    CompoundButton buttonView, boolean isChecked) {
                                Model element = (Model) holder.chkbxFavrowsel
                                        .getTag();
                                element.setSelected(buttonView.isChecked());
                                bSelected[position] = isChecked;

                            }
                        });
                holder.chkbxFavrowsel.setTag(mlist.get(position));
                holder.ratingBar1.setOnRatingBarChangeListener(l);
            } else {
                row = convertView;
                ((ViewHolder) row.getTag()).chkbxFavrowsel.setTag(mlist
                        .get(position));
            }

            RowModel model = getModel(position);
            ViewHolder holder = (ViewHolder) row.getTag();
            holder.ratingBar1.setTag(new Integer(position));
            holder.ratingBar1.setRating(model.rating);
            holder.imgvFavrowiconappicon.setImageDrawable(alIcon[position]);
            holder.txvxFavrowiconappname.setText(alAppName.get(position)
                    .toString());
            holder.chkbxFavrowsel.setChecked(mlist.get(position).isSelected());

            return (row);
        }
    }
}
</code></pre>
