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

  • Home
  • SEARCH
  • 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 7689531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:11:11+00:00 2026-05-31T20:11:11+00:00

I am new to Android and Java programming. I have a class which implements

  • 0

I am new to Android and Java programming. I have a class which implements a custom cursor adapter. The problem is I need to be able to access some of the information in the cursor adapter within a listener. See below:

    public class MyCursorAdapter extends CursorAdapter{  
        public MyCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
            super(context, c);
        }

        public void bindView(View view, Context context, Cursor cursor) {
            TextView ratingBarName = (TextView)view.findViewById(R.id.ratingbar_name);
            ratingBarName.setText(cursor.getString(
                cursor.getColumnIndex(MyDbAdapter.KEY_NAME)));

            RatingBar ratingBar = (RatingBar)view.findViewById(R.id.ratingbar);
            ratingBar.setRating(cursor.getFloat(
                cursor.getColumnIndex(MyDbAdapter.KEY_RATING)));


            RatingBar.OnRatingBarChangeListener barListener = 
                new RatingBar.OnRatingBarChangeListener() {
                public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
                    MyDbAdapter db = MyActivity.this.getDbHelper();

                    // NEED ACCESS TO CURSOR HERE SO I CAN DO:
                    // cursor.getColumnIndex(MyDbAdapter.KEY_ROWID);
                    // AND THEN USE THE ROW ID TO SAVE THE RATING IN THE DB
                    // HOW DO I DO THIS?
                }

            }               
            ratingBar.setOnRatingBarChangeListener(barListener);
       }

       public View newView(Context context, Cursor cursor, ViewGroup parent) {
           LayoutInflater inflater = LayoutInflater.from(context);
           View view = inflater.inflate(R.layout.ratingrow, parent, false);
           bindView(view, context, cursor);
           return view;
       }
   }

Thank you very much.

  • 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-05-31T20:11:12+00:00Added an answer on May 31, 2026 at 8:11 pm

    Set as a tag for the RatingBar the KEY_ROWID before you enter in the listener and then in the listener retrieve the tag and use it on the cursor:

    //...
    ratingBar.setRating(cursor.getFloat(cursor.getColumnIndex(MyDbAdapter.KEY_RATING)));
    ratingBar.setTag(new Long(cursor.getLong(MyDbAdapter.KEY_ROWID)));
    RatingBar.OnRatingBarChangeListener barListener = 
                    new RatingBar.OnRatingBarChangeListener() {
                    public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
                        MyDbAdapter db = MyActivity.this.getDbHelper();                       
                        long theIdYouWant = (Long) ratingBar.getTag();                    
                        //use the id 
                    }
    
                }    
    
    //...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android & Java programming but have been programming in .NET for
I'm new to Android programming however I do have some Java experience. What I
I am new to Java programming / Android development - but I have been
I'm fairly new to Android programming and to Java in general, but I have
I'm new in Java and in programming on android. Have a look at this
I'm new to android and I have not done any Java programming for probably
I am new to Android/java programming. I really have no clue what I am
I am new at android development and java programming, but I have decided to
I'm new to Java programming, I am programming Java 1.6 with Android. I have
I'm still new to programming/Java/Android so I'm trying to understand everything I do and

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.