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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:29:37+00:00 2026-05-23T06:29:37+00:00

I have a sqlite database. I am able to query it and get a

  • 0

I have a sqlite database. I am able to query it and get a cursor with results. It populates the data well in a list view which has 1 image view and 2 text views. However the cursor result set which has 2 columns is of text. This is shown in the 2 text views. Everything till here works fine.

Now based on the value of one of the column I need to show different images in the image view in the list item. How do I do this. As of now I am using the below code. How do I modify it to get a image view changes based on the column value?

Cursor mCursor = mDbHelper.fetchAll();
startManagingCursor(mCursor);

    String[] from = new String[]{"TITLE","BODY"};
    int[] to = new int[]{R.id.text1,R.id.text2};

    SimpleCursorAdapter listValues = 
        new SimpleCursorAdapter(this, R.layout.row_item, mCursor, from, to);
    setListAdapter(listValues );
  • 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-23T06:29:38+00:00Added an answer on May 23, 2026 at 6:29 am

    I got this done using code below

    listValues.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

            @Override
            public boolean setViewValue(View view, Cursor cursor, int column) {
                if( column == col ){ 
                    ImageView img = (ImageView) ((View)view.getParent()).findViewById(R.id.icon);
                    if(cursor.getString(col).equals("Y"))
                    {
                        img.setBackgroundResource(R.drawable.img1);
                    }
                    else
                    {
                        img.setBackgroundResource(R.drawable.img2);                        
                    }
                    return true;
                }
                return false;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app which communicates to webserver. This webserver has SQLite database on
I am not able to delete data from SQlite database. I have created a
I have a datalogging application (c#/.net) that logs data to a SQLite database. This
I have a DataTable which I want to save to a SQLite Database Table.
I have created sqlite database using phonegap. I am able to access that databse
in my application i have used sqlite database. I am able to insert the
I have a pre-established SQLite Database in my application. It has a table with
I have an sqlite database full of huge number of URLs and it's taking
I have a SQLite database that contains a huge set of log messages. I
I have an sqlite database, and I would like to keep it read-only without

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.