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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:14:48+00:00 2026-05-26T18:14:48+00:00

I have a listview which populates its content from SQLite Database. Here’s my code:

  • 0

I have a listview which populates its content from SQLite Database.
Here’s my code:

ListView listView = (ListView) findViewById(R.id.lstText);
        listView.setOnItemClickListener(this);
        listView.setAdapter(new MySimpleCursorAdapter(this, R.layout.listitems,
                managedQuery(Uri.withAppendedPath(Provider.CONTENT_URI,
                        Database.Project.NAME), new String[] { BaseColumns._ID,
                        Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION, Database.Project.C_ORGANIZATIONTITLE}, null, null, null),
                new String[] { Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION, Database.Project.C_ORGANIZATIONTITLE}, new int[] {
                        R.id.txt_title, R.id.image, R.id.txt_list_desc, R.id.txt_org}));

I want to put an extra String to some TextViews above when its displayed on the list. For example, I want to add a String with the word “from” on R.id.txt_org, before the populated String from the database which is Database.Project.C_ORGANIZATIONTITLE

Let’s say the populated String is: New Organisation,
with an extra String “from” what will be displayed is: from New Organisation

Can anybody help me with that? Thank you very much.

EDITED:

FYI, this is my SimpleCursorAdapter method:

class MySimpleCursorAdapter extends SimpleCursorAdapter {

        public MySimpleCursorAdapter(Context context, int layout, Cursor c,
                String[] from, int[] to) {
            super(context, layout, c, from, to);
            loader = new ImageLoader(context);
            this.context = context;
        }

        Context context=null;
        ImageLoader loader = null;

        public void setViewImage(ImageView v, String value) {
            v.setTag(value);
            loader.DisplayImage(value, context, v);
        }
    }
  • 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-26T18:14:49+00:00Added an answer on May 26, 2026 at 6:14 pm

    Since you’re already using a custom adapter, override the adapter’s bindView() and newView() methods, rather than getView(). That way you will not have to manually deal with recycling the row’s view.

    Within these method you can get the data from the resulting Cursor and manipulate it before binding it to your row’s view.

    • GetView Vs. BindView in a custom CursorAdapter?
    • How to override CursorAdapter bindView

    //Edit: some more code below. Note that this is just a rough outline and by no means complete or tested.

    class MySimpleCursorAdapter extends SimpleCursorAdapter {
    
        private ImageLoader mLoader = null;
        private LayoutInflater mInflater = null;
        private int mBusinessNameIndex = -1;
        private int mSmallImageIndex = -1;
    
        public MySimpleCursorAdapter(Context context, int layout, Cursor c,
                String[] from, int[] to) {
            super(context, layout, c, from, to);
            mLoader = new ImageLoader(context);
            mInflater = getLayoutInflater();    
            mBusinessNameIndex = c.getColumnIndexOrThrow(Database.Project.NAME);
            mSmallImageIndex = c.getColumnIndexOrThrow(Database.Project.C_SMALLIMAGE);
        }
    
        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            return mInflater.inflate(R.layout.row, null);
        }
    
        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            // Get your views from 'view'
            TextView someTextView = (TextView) view.findViewById(R.id.xxx);
            ImageView someImageView = (ImageView) view.findViewById(R.id.yyy);
            // Set the data
            someTextView.setText("from " + cursor.getString(mBusinessNameIndex));
            mLoader.DisplayImage(cursor.getString(mSmallImageIndex ), context, someImageView);      
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview which loads its data from sqlite database. Each row in
I have the following code, which basically takes values from a database and populates
I have a listview which has its datasource changed after update of a search
I have a list view which is populated via records from the database. Now
I have a following problem. I have a ListView which returns data from SQL
In my application I have a listView . I want to update its content
I have a ListView which sometimes I need to put around 10000 items in.
I have a ListView which is using a GridView to display a DataTable and
I have a WPF ListView which repeats the data vertically. I cannot figure out
This is a very common scenario: displaying images in a ListView which have to

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.