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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:05:06+00:00 2026-06-05T11:05:06+00:00

I have already created a dynamic list view that passes text to a SimpleAdapter,

  • 0

I have already created a dynamic list view that passes text to a SimpleAdapter, however I would like to pass information to make an image appear from the drawable folder. Here is the XML layout for each row:

<ImageView 
    android:id="@+id/sport_icon"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    />    
<TextView  
    android:id="@+id/item_title"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:padding="2dp"
    android:textSize="20dp" />
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right" >
<TextView  
    android:id="@+id/item_subtitle"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="2dp"
    android:textSize="13dp" />
</LinearLayout>
</LinearLayout>

and the bit of code creating the list:

//fill in the list items from the XML document
    for (int i = 0; i < nodes.getLength(); i++) {                           
        HashMap<String, String> map = new HashMap<String, String>();    

        Element e = (Element)nodes.item(i);
        map.put("id", XMLfunctions.getValue(e, "fixture_id"));
        map.put("sport", XMLfunctions.getValue(e, "sport"));
        map.put("teams", XMLfunctions.getValue(e, "team_2") + " v " + XMLfunctions.getValue(e, "team_2"));
        mylist.add(map);            
    }       

    //Make a new listadapter
    ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.fixture, new String[] { "sport", "teams" }, new int[] { R.id.item_title, R.id.item_subtitle });

    setListAdapter(adapter);

Now at the moment when I pass the string sport it just displays the text such as ‘football’ in the item_title text view. But as I know what the sport is I would like to be able to display an icon in the sport_icon imageview. An example of the sport icon location would be @drawable/icon_football.

Many thanks.


The answer here was creating a BaseAdapter with the ListView as suggested by Frank below. If anyone else is looking to do the same thing but has no idea where to start I highly recommend watching http://www.youtube.com/watch?v=pVs4qKmenQM. This video is well put together and explains everything you need to know.

🙂

  • 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-06-05T11:05:09+00:00Added an answer on June 5, 2026 at 11:05 am

    You are going to have to extend something like BaseAdapter and check what your position is in getView() and then accordingly set what image you would like to use.
    SimpleAdapter only works nice if ALL the items are have the exact same format and it’s very simple.

    Here is an ok example.
    http://thinkandroid.wordpress.com/2010/01/13/custom-baseadapters/

    But I would really recommend watching the Romain and Adam’s Google IO Video
    http://www.youtube.com/watch?v=wDBM6wVEO70

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

Sidebar

Related Questions

I have already created a webpart to show the data from list, but I
I am building an Day View calendar app. I have already created the empty
I would like to create form based on dynamic parameters that are stored in
I have created a turing-complete programming language (already proven) so it must be possible
I was already running a sub-website under following path http://example.com/sub-site/ Now, I have created
Hey I have dynamic image begin created with imagecreate(), and I have random values
I created a dynamic table in ASP/VBScript that populates a table from a recordset.
I have created a custom title bar as shown in this example http://staticallytyped.wordpress.com/2011/03/18/android-dynamic-and-custom-title-bars/ A
How can I get an already existing object spring managed? I would like to
I have created a dynamic form using vbscript. It displays fine but when I

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.