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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:36:06+00:00 2026-05-15T22:36:06+00:00

I have a custom CursorAdapter that is taking items from a database and displaying

  • 0

I have a custom CursorAdapter that is taking items from a database and displaying them in a listview. If possible, I would like to display only certain elements based on some boolean value within a database element. Here is something similar to what I would like to do:

package itp.uts.program;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;
//Adapter tests if an element is read or unread, and bolds the items that are unread
public class BoldAdapter extends CursorAdapter{

private final LayoutInflater mInflater;
public BoldAdapter(Context context, Cursor c, boolean autoRequery) {
    super(context, c, autoRequery);
    mInflater = LayoutInflater.from(context);
}
public BoldAdapter(Context context, Cursor c) {
    super(context, c);
    mInflater = LayoutInflater.from(context);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {

}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    //Creates a view to display the items in
    final View view = mInflater.inflate(R.layout.notes_row, parent, false);
    TextView textRequestNo = (TextView) view.findViewById(R.id.text1);
    TextView textMessage = (TextView) view.findViewById(R.id.text2);
    StringBuilder requestNo = new StringBuilder(cursor.getString(cursor
            .getColumnIndex("requestNo")));
    StringBuilder message = new StringBuilder(cursor.getString(cursor
            .getColumnIndex("Message")));

    //Sets the text fields as elements from the database
    textRequestNo.setText(requestNo);
    textMessage.setText(message);

    if (cursor.getString(cursor.getColumnIndex("Read")).equals("true"))
    {//Tests if the item is unread
        **//DO NOT SHOW THE ELEMENT, HOW DO I DO THIS?**
    }

    return view;
}

}

  • 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-15T22:36:07+00:00Added an answer on May 15, 2026 at 10:36 pm

    Ideally, you just filter out the rows you don’t want in your database query.

    If, for whatever reason, that is not possible, create a wrapping adapter that filters out the rows you do not want. Here is an AdapterWrapper base class you can use to help.

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

Sidebar

Related Questions

I have a ListView of items with checkboxes. I have a custom CursorAdapter that
I have a listview from an SQLDatabase using custom CursorAdaptor. I would like to
I have a ListView with a custom CursorAdapter feed from a MatrixCursor . Each
I have a subclass of CursorAdapter and I would like to filter my listview.
I have a database, a ListView , and a CustomCursorAdapter that extends CursorAdapter .
I have a ListView with a custom adapter that extends CursorAdapter. that ListView also
I have a nicely working custom CursorAdapter with customized ListView. This view allows the
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom drupal module. I receive result from a webservice that I need
I have custom exceptions in my django project that look like this: class CustomFooError(Exception):

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.