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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:19:47+00:00 2026-05-27T08:19:47+00:00

I’m attempting to create a class that extends a CursorAdapter in order to display

  • 0

I’m attempting to create a class that extends a CursorAdapter in order to display a RatingBar and text in the ListView, using its newView and bindView methods.This is an attempt to go further with the Notepad tutorials from the Dev website.My problem is that the program crashes manly because I’m implementing the methods wrong , although there may be other problems of implementation in this class or the filldata method.My question is what is the correct way to write the code so that I can display a rating bar in a listview along with other textviews?Thank you

package com.android.demo.notepad3;

import android.content.Context;
import android.database.Cursor;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.EditText;
import android.widget.RatingBar;

public class NoteA extends BaseAdapter{
    private final LayoutInflater mInflater;
    private EditText mTitleText;
    private EditText mBodyText;
    private RatingBar mRatingBar;
    private NotesDbAdapter mDbHelper;
    Context c1;
    static Cursor c;
    private static boolean autoRequery;


    public NoteA(Context context, int layout, Cursor c, String[] from, int[] to) {
    super(context, c, autoRequery);
    mInflater = LayoutInflater.from(context);
    c1=context;
    this.c=c;
     mDbHelper = new NotesDbAdapter(context);
      mDbHelper.open();

    }
    @Override
public View getView(int arg0, View arg1, ViewGroup arg2) {


      final View view = inflater.inflate(R.layout.notes_row, null);
      mTitleText = (EditText) view.findViewById(R.id.title);
      mBodyText = (EditText) view.findViewById(R.id.body);
      mRatingBar= (RatingBar) view.findViewById(R.id.ratingbar);

      mTitleText.setText(c.getString(
             c.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
     mBodyText.setText(c.getString(
             c.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
     mRatingBar.setRating(c.getFloat(
             c.getColumnIndexOrThrow(NotesDbAdapter.KEY_RATING)));

    return view;
}
     // @Override
//public void bindView(View view, Context context, Cursor cursor) {

//}

//@Override
//public View newView(Context context, Cursor cursor, ViewGroup parent) {
//final View view = mInflater.inflate(R.layout.notes_row, parent, false);
//bindView(view, context, cursor);
//return view;
//}



}

Filldata method from the Notepad3 class wich extends a ListActivity

 private void fillData() {
       Cursor notesCursor = mDbHelper.fetchAllNotes();
       startManagingCursor(notesCursor);

        // Create an array to specify the fields we want to display in the list (only TITLE)
       String[] from = new String[]{NotesDbAdapter.KEY_TITLE,NotesDbAdapter.KEY_BODY};

       // and an array of the fields we want to bind those fields to (in this case just text1)
       int[] to = new int[]{R.id.text1,R.id.text2};

         //Now create a simple cursor adapter and set it to display
        ListAdapter notes = new NoteA(this, R.layout.notes_row, notesCursor, from, to);
        setListAdapter(notes);
    }
  • 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-27T08:19:47+00:00Added an answer on May 27, 2026 at 8:19 am

    You need to create your own custom ListView using BaseAdapter..

    Like this..

    public class MyCustomAdapter extends BaseAdapter{
    private Context context;
    
    private List<Phonebook> listPhonebook;
    
    public PhonebookAdapter(Context context, List<Phonebook> listPhonebook) {
        this.context = context;
        this.listPhonebook = listPhonebook;
    }
    
    public int getCount() {
        return listPhonebook.size();
    }
    
    public Object getItem(int position) {
        return listPhonebook.get(position);
    }
    
    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup viewGroup) {
     outInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.phone_row, null); //This should be your Layout with the rating bar
    
     //Here you can get your widgets for use like this..
    
      TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
     //You can do the same thing for the Rating bar you.
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.