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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:11:45+00:00 2026-05-27T01:11:45+00:00

I have done the notepad tutorial of the google webside. There are these tree

  • 0

I have done the notepad tutorial of the google webside. There are these tree strings:

public static final String KEY_TITLE = "title";
public static final String KEY_BODY = "body";
public static final String KEY_ROWID = "_id";

I only put the values “0”, “1”, “2”, “3” in my KEY_TITLE. Instead of showing the strings in a TextView of my Listview, I want to show the images from this array:

private int icons[] = new int[] {R.drawable.icon1, 
R.drawable.icon2, R.drawable.icon3, R.drawable.icon4};

e.g. If KEY_TITLE ist “0” I want to show the the image icon1. etc….

Now I have the problem, that the SimpleCursorAdapter can only map to TextViews. How can I tell the SimpleCursorAdapter, that it has to map the string values to the number of icons in my icons[]-string?

Can anybody help me, how to write a new SimpleCursorAdapter? Or is it not necessary?

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

    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};
    int[] to = new int[]{R.id.image};

    SimpleCursorAdapter notes = 
        new SimpleCursorAdapter(this, R.layout.notes_row, notesCursor, from, to);
    setListAdapter(notes);
}

Thanks a lot.

Felix

  • 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-27T01:11:45+00:00Added an answer on May 27, 2026 at 1:11 am

    Hi FelixA why a SimpleAdapter?
    If i may make a suggestion switch to CustomBasAdapter, it gices you more options to tweak for later use, also adding icons, images etc.
    Follow the description on this site to make the adapter.
    You can later on tweak it and add the icons pictures etc.

    public MyCustomBaseAdapter(Context context, ArrayList<SearchResults> results, int[] images) {
     super();
       mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       this.images = images;
       searchArrayList = results;
      }
    
    public View getView(int position, View convertView, ViewGroup parent) {
       ViewHolder holder;
    
       if (convertView == null) {
        holder = new ViewHolder();
        convertView = mInflater.inflate(R.layout.test, null);
    
        holder.imgViewLogo =(ImageView)convertView.findViewById(R.id.imgIcon);
     ....
     convertView.setTag(holder);
    } 
    
     ....
     holder.imgViewLogo.setImageResource(images[position%4]); // 4 icons to add
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done like these it not working? public class AnimationActivity extends Activity{ private
I have done few sites for my clients but I came to know these
I have a question about Sql database in android.Now Ive done the all Notepad
I have done Java and JSP programming in the past, but I am new
I have done a bit of testing on this myself (During the server side
I have done a bit of research into this and it seems that the
I have done some searches looking for information about how to do logging with
I have done a little Django development, but it has all been in a
I have done this: $ z() { echo 'hello world'; } How do I
I have done jQuery and Ajax, but I am not able to get the

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.