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 892441

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:03:20+00:00 2026-05-15T14:03:20+00:00

I am writing a app for android 1.5. I want to use a complex

  • 0

I am writing a app for android 1.5.
I want to use a complex listview to display my data.
I want to show a ImageView of a drawable object in my List item.

I learned from a demo:

------> listData.put("Img", listData.put("Img", R.drawable.XXX));
listData.put("Time", "100");
listItems.add(listData);

It can display correctly, however, I want to change Img at runtime, The image maybe generated at run-time, so I change the code as follow, but it falls.
Can anyone help me ? many thanks!

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.item_list);
    itemListView = (ListView) findViewById(R.id.listview);
    ArrayList<HashMap<String, Object>> listItems = new ArrayList<HashMap<String, Object>>();
    for(int i = 0;i <XXX.size(); ++i) {
        HashMap<String, Object> listData = new HashMap<String, Object>();
--------->/*1)*/  listData.put("Img", new Drawable(XXX));
        /*2)*/  listData.put("Time", "100");
        /*3)*/  listItems.add(listData);
    }
    SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItems, R.layout.listitem, new String[] { "Img", "Time"}, new int[] { R.id.listitem_img, R.id.listitem_time });
    itemListView.setAdapter(listItemAdapter);
}

listitem.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    android:layout_width="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" 
    android:paddingBottom="4dip"
    android:paddingLeft="12dip" 
    android:paddingRight="12dip">

    <ImageView 
        android:id="@+id/listitem_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="12dip"/>

    <TextView
        android:id="@+id/listitem_time" 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:textSize="20dip" />

</LinearLayout>
  • 0 0 Answers
  • 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

Sidebar

Related Questions

I am writing a app for android 1.5. I want to use a complex
I am writing an android app. I want to pass some data across the
I'm writing an android app and in it I want to have a sort
I'm writing an app that will need to make use of Timer s, but
I'm writing an Android App and I'm looking for the fastest (In terms of
I'm writing an Android application that I want to be able to send requests
I'm currently writing an app in Android that works with the GPS. At the
I am writing an Android app, part of which will be a survey involving
I'm writing an Android app where users can upload video to Youtube. I'd like
I'm developing an android app (if you want more info http://www.txty.mobi ) and 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.