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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:31:06+00:00 2026-06-05T02:31:06+00:00

i am make application in which i am display rate-bar on listview and also

  • 0

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 list item and scroll list down and get back to top, rated item was clear there are no rating display on that particular item

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

Here is my 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<Comment> appname;
    ArrayList<Comment> Packagenm;
    Drawable[] alIcon;
    static float[] rating;

    public ListViewCustomAdapter(Context context, ArrayList<Comment> appname,
            ArrayList<Comment> 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 -> " +
        // 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;

    }
}
  • 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-06-05T02:31:08+00:00Added an answer on June 5, 2026 at 2:31 am

    You getItemId() method in the adapter class should return position not 0.

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

    UPDATE:

    I had recently added ListView with CheckBox Scrolling Issue. Same should apply here, just try to get the position of ratingbar inside onRatingChanged() using ratingBar.getTag(); and set the current rating to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an application which make use of display lists offered by OpenGL. My
I want to make an console application of c which can run other applications
I have an android application, which needs to display an image and make that
I'm trying to make an application in which both the developer and the end
Suppose I want to make a Web application which uses a fixed width and
I try to make an Android application which communicates with a non-standard ISO15693 (NFC-V)
I have a relatively simple application which I need to make native Mac OSX
I have been working on an application which allows the user to make a
i'm currently trying to make a asp.net mvc3 app. in the sample application which
So, I am planning to make an application (PHP/MySQL) which deals a lot with

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.