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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:03:38+00:00 2026-05-23T09:03:38+00:00

I am trying to make a listview, every row contains an imageview and two

  • 0

I am trying to make a listview, every row contains an imageview and two text views. The image and the second textview is shown but the first textview is blank…Can’t figure out what’s wrong…I can’t wrap my head around custom list adapters…I have read http://commonsware.com/Android/excerpt.pdf to.

My data is loaded correctly to the arraylist.
My code:

private class SongAdapter extends ArrayAdapter<Szam> {

        private ArrayList<Szam> items;

        public SongAdapter(Context context, int textViewResourceId,     ArrayList<Szam> items) {
                super(context, textViewResourceId, items);
                this.items = items;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row, null);
                }
                Szam o = items.get(position);
                if (o != null) {
                        TextView tt = (TextView) v.findViewById(R.id.firstLine);
                        TextView bt = (TextView) v.findViewById(R.id.secondLine);
                        if (tt != null) {
                              tt.setText(o.getArtist());                            }
                        if(bt != null){
                              bt.setText(o.getTitle());
                        }
                }
                return v;
        }

And my xml layout:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"     android:minHeight="?android:attr/listPreferredItemHeight"
android:layout_height="wrap_content" android:padding="6dip">

<TextView android:id="@+id/secondLine" android:layout_width="fill_parent"
    android:layout_height="26dip" android:layout_toRightOf="@+id/icon"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" android:singleLine="true"
    android:ellipsize="marquee"
    android:text="Simple application that shows how to use RelativeLayout" />

<TextView android:id="@+id/firstLine" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_toRightOf="@+id/icon"
    android:layout_alignParentRight="true" android:layout_alignParentTop="true"
    android:layout_above="@id/secondLine"
    android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical"
    android:text="My Application" />
<ImageView android:layout_marginRight="6dip" android:id="@+id/icon"
    android:src="@drawable/play" android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:layout_alignParentLeft="true"></ImageView>

 </RelativeLayout>

The corrected layout is:

<TextView android:id="@+id/secondLine1" android:layout_width="fill_parent"
    android:layout_height="wrap_content"  android:layout_toRightOf="@+id/icon"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" android:singleLine="true"
    android:ellipsize="marquee"
    android:textColor="#ffffff"

    android:textSize="12sp"
    android:text="Simple application that shows how to use RelativeLayout" />

<TextView android:id="@+id/firstLine1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_toRightOf="@+id/icon"
    android:layout_alignParentRight="true" android:layout_alignParentTop="true"
    android:ellipsize="marquee"
    android:textColor="#ffffff"

    android:textSize="16sp" 
    android:layout_alignWithParentIfMissing="true"
    android:text="My Application" />

<ImageView android:layout_marginRight="6dip" android:id="@+id/icon"
    android:src="@drawable/play" android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:layout_alignParentLeft="true"></ImageView>

  • 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-23T09:03:39+00:00Added an answer on May 23, 2026 at 9:03 am

    Can’t you use LinearLayouts?

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
        android:minHeight="?android:attr/listPreferredItemHeight" android:layout_height="wrap_content" android:padding="6dip">
        <ImageView android:layout_marginRight="6dip" android:id="@+id/icon" android:src="@drawable/play" android:layout_width="wrap_content"
            android:layout_height="fill_parent"></ImageView>
        <LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:orientation="vertical"
            android:layout_height="wrap_content">
            <TextView android:text="My Application" android:layout_height="wrap_content" android:gravity="center_vertical" android:id="@+id/firstLine"
                android:layout_width="fill_parent"></TextView>
            <TextView android:singleLine="true" android:text="Simple application that shows how to use RelativeLayout" android:layout_height="wrap_content"
                android:ellipsize="marquee" android:id="@+id/secondLine" android:layout_width="fill_parent"></TextView>
        </LinearLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a listview with a text and an image for each
I'm trying to make 'dynamic' listview that contains 0-2 headers and 0-1 footer(based on
I'm trying to make an application with repeatable background in a listview, but i
I am trying to make a simple dictionary bound image listview where key is
I'm trying to make a custom listview that will hold views of custom objects,
I'm trying to make an Expandable ListView, but I don't know how to retrieve
I'm trying to make a screen with a TextView at the top, the ListView
I'm trying to make a ListView with 2 items in each 1 list item
I'm trying to make a context menu for my listview, so when a user
I was wondering : I'm trying to make an app that as a Listview,

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.