ratingbar issue in android
<p>i am make application in which i am display rate-bar on listview and also display other 2 widget. i got some problem in this adapter is that when i am rate any <strong>list item</strong> and scroll list down and get back to top, rated item was clear there are no rating display on that particular item </p>

<p>let say i have give 3 star to 1st item and scroll down and get back to it, and it became 0</p>

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

<pre><code>package com.AppFavorits;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;

public class ListViewCustomAdapter extends BaseAdapter {

    public Context context;
    LayoutInflater inflator;
    ArrayList&lt;Comment&gt; appname;
    ArrayList&lt;Comment&gt; Packagenm;
    Drawable[] alIcon;
    static float[] rating;

    public ListViewCustomAdapter(Context context, ArrayList&lt;Comment&gt; appname,
            ArrayList&lt;Comment&gt; Packagenm, Drawable[] alIcon) {
        super();

        this.context = context;
        this.appname = appname;
        this.Packagenm = Packagenm;
        this.alIcon = alIcon;
        inflator = LayoutInflater.from(context);
        rating = new float[appname.size()];

        // Log.i("Parse adapter ", " Date adapter -&gt; " +
        // arr_ScheduledDepartureTime[1]);

    }

    public int getCount() {
        // TODO Auto-generated method stub
        return appname.size();

    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return appname.get(position);
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    public static class ViewHolder {
        ImageView imgvFavrowiconappicon;
        TextView txvxFavrowiconappname;
        RatingBar ratingBar1;

    }

    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        // View vi=convertView;
        // View view = null;
        ViewHolder viewholder;

        if (convertView == null) {
            viewholder = new ViewHolder();
            convertView = inflator.inflate(R.layout.outbox_list_item, null);
            viewholder.ratingBar1 = (RatingBar) convertView
                    .findViewById(R.id.ratingBar1);
            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;
                     * 
                     * LinearLayout parent=(LinearLayout)ratingBar.getParent();
                     * TextView label=(TextView)parent.findViewById(R.id.label);
                     */

                    // label.setText(model.toString());
                    Log.i("TAg", "rate" + rating);
                }
            };

            viewholder.ratingBar1.setOnRatingBarChangeListener(l);

            viewholder.txvxFavrowiconappname = (TextView) convertView
                    .findViewById(R.id.txvxFavrowiconappname);
            viewholder.imgvFavrowiconappicon = (ImageView) convertView
                    .findViewById(R.id.imgvFavrowiconappicon);
            // viewholder.ratingBar1 = (RatingBar)
            // convertView.findViewById(R.id.ratingBar1);
            convertView.setTag(viewholder);

        } else {
            viewholder = (ViewHolder) convertView.getTag();

        }

        viewholder.imgvFavrowiconappicon.setImageDrawable(alIcon[position]);
        viewholder.txvxFavrowiconappname.setText(appname.get(position)
                .toString());

        viewholder.ratingBar1.setTag(new Integer(position));
        viewholder.ratingBar1.setRating(0);
        /*
         * viewholder.ratingBar1.setOnTouchListener(new OnTouchListener() {
         * 
         * @Override public boolean onTouch(View v, MotionEvent event) { if
         * (event.getAction() == MotionEvent.ACTION_UP) { // TODO perform your
         * action here } return true; } });
         */
        return convertView;

    }
}
</code></pre>
