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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:36:47+00:00 2026-05-16T03:36:47+00:00

Note that my activity is NOT extending ListActivity; just Activity. I have a list

  • 0

Note that my activity is NOT extending ListActivity; just Activity.

I have a list view with a custom layout as follows:

(res/layout/list_item.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal"
>
<ImageView
 android:id="@+id/icon"
 android:layout_width="30dip"
 android:paddingTop="15dip"
 android:layout_height="wrap_content"
 android:src="@drawable/icon_default"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:textColor="#ffffff"
/>
    </LinearLayout>

I’m then setting the adapter for the ListView to an ArrayAdapter using an ArrayList, here called ‘machines’.

ListView rooms = (ListView)findViewById(R.id.machines);
ArrayAdapter<String> aa = new ArrayAdapter<String>(getApplicationContext(), R.layout.list_item, android.R.id.text1, machines);
rooms.setAdapter(aa);

How would I go about doing a similar thing for the ImageView field?

  • 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-16T03:36:47+00:00Added an answer on May 16, 2026 at 3:36 am

    With an ArrayAdapter, you would need to override getView() and do more of the work yourself. You can either inflate the row yourself (getLayoutInflater().inflate()) or chain to the superclass to get your row. Then, find the ImageView in the row and set its image based on the position parameter supplied to getView(). Return the resulting row.

    Here’s a free excerpt from one of my books that covers much of this.

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

Sidebar

Related Questions

I have created a listview that sits inside a larger activity (the list view
I have the following scenario (note that activity A has launchMode=singleTop ): Activity A
I have a custom Android Service (with no associated Activity) that needs to implement
(note that this question is not about CAS, it's about the May fail spuriously
Please note that I'm not asking how but why. And I don't know if
(Please note that I have seen a similar question on StackOverflow recently, however I
I'll preface this question with the note that I have looked at this similar
I want to be able to start an Activity that is not part of
I have an already established activity that must extend another activity so I'd much
I want to create a dynamically extending layout that may grow reflecting to user's

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.