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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:17:39+00:00 2026-06-13T16:17:39+00:00

I want two display two Images and and two Text Views in each row

  • 0

I want two display two Images and and two Text Views in each row of the List View. I have tried this but images are not displayed.

This is code of Customized list view source, custom_listview.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >


<RelativeLayout
    android:id="@+id/custom_ListView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:gravity="center"
    android:padding="20dp" >

    <ImageView
        android:id="@+id/imgBook1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="30dp"
        android:src="@drawable/book1" />

    <TextView
        android:id="@+id/txtTitleBook1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imgBook1"
        android:text="Book1 Title Here" />

    <ImageView
        android:id="@+id/imgBook2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_toRightOf="@+id/imgBook1"
        android:src="@drawable/book2" />

    <TextView
        android:id="@+id/txtTitleBook2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/txtTitleBook1"
        android:layout_alignBottom="@+id/txtTitleBook2"
        android:layout_toRightOf="@+id/txtTitleBook1"
        android:text="Book2 Title Here" />

</RelativeLayout>

</RelativeLayout>

and here is main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

And here is my Java code, Main.java:

    package my.islamic.books.lib.app;

    import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Home extends ListActivity {

    String[] booksTitles = { "Book1", "Book2", "Book3", "Book4" };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_activity);

        setListAdapter(new MyAdapter(this, android.R.id.text1, booksTitles));

    }

    private class MyAdapter extends ArrayAdapter<String> {

        int[] booksCoverPhotos = { R.id.imgBook1, R.id.imgBook2, R.id.imgBook1,
                R.id.imgBook2};

        public MyAdapter(Context context, int resource, String[] objects) {
            // super(context, resource, textViewResourceId, objects);
            super(context, resource, objects);

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            View row = inflater.inflate(R.layout.listview_body, parent, false);

            ImageView imgView_book1 = (ImageView) row
                    .findViewById(R.id.imgBook1);
            ImageView imgView_book2 = (ImageView) row
                    .findViewById(R.id.imgBook2);
            TextView txtView_bookTitle1 = (TextView) row
                    .findViewById(R.id.txtTitleBook1);
            TextView txtView_bookTitle2 = (TextView) row
                    .findViewById(R.id.txtTitleBook2);

            txtView_bookTitle1.setText(booksTitles[position]);
            imgView_book1.setImageResource(booksCoverPhotos[position]);
            imgView_book2.setImageResource(booksCoverPhotos[position]);
            txtView_bookTitle2.setText(booksTitles[position]);

            return row;
        }

    }// end class

}

And also when I’m making comment any imgView_book1 or imgView_book2 in the above Java code, then it’s displaying one image in each row of listView, but why not both images?

  • 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-13T16:17:40+00:00Added an answer on June 13, 2026 at 4:17 pm

    The ImageView method setImageResource(int resId) gets an id of your drawable as a parameter.
    For example, R.drawable.your_image.
    Read this document.

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

Sidebar

Related Questions

I have tried to do this here http://wonderfl.net/c/9Kdv but what I want is not
i have two foreach loop to display some data, but i want to use
I have got two images one that i want to display on the top
I want to display two images that I have no idea when they will
I would like to display an image composed of two images. I want image
Hi i want to display join result of two tables but don't want to
I have two tables and I want to display only the child ID that
I have two possible widths for a string i want to display in a
I have a ListView which I've created a custom view for each row. My
I want to get a list of product images from SQL to display 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.