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

The Archive Base Latest Questions

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

I want to create a listviewitem in a listactivity. The listviewitem will be a

  • 0

I want to create a listviewitem in a listactivity.
The listviewitem will be a textview and an image.

But I have a case that there is no image to put in the imageview I will want the textview to take the whole listviewitem.

I do not want to use different XML layouts for these cases because I have same issue but with 3 images (n of the 3 can be shown).

I need some sample code for dynamic adding image views….

Also – I am using an adapter for this list…

  • 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:12:05+00:00Added an answer on May 26, 2026 at 6:12 pm

    I have no time to post code, but you could do something like this:

    1. Create a Item List Layout as a Relative o LinearLayout with your TextView and your ImageView
    2. in your Adapter.getView you should inflate your Item List Layout and then set the ImageView’s visibility to GONE whenever you don’t have an image.

    EDITED:

    Here is one layout to use as your itemLayout:

    <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/img_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
    <TextView android:id="@+id/text_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create constructor that will take one or more integers and save it
i want create image animation , i have 50 images with png format now
I want create object from Canvas3D class(in java) but my Compiler doesn't have this
I want to create a function that performs a function passed by parameter on
I want to create a simple http proxy server that does some very basic
I want create a DataSet class which is basically a list of samples. But
I want create a button option that takes the entire datalist and converts it
I want create a ruby script that I can run on the command line
I want create Word document from another Word document, but I need replace some
I want create listview without layout_height. I mean if there is 100 item in

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.