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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:06:01+00:00 2026-06-08T16:06:01+00:00

I am trying to create a list of TextView’s in my Android app of

  • 0

I am trying to create a list of TextView’s in my Android app of name’s and organizations. However, the whole list is the same, for example:

Joe's work for Construction Co.
15hrs of 60hrs
Joe's work for Construction Co.
15hrs of 60hrs
Joe's work for Construction Co.
15hrs of 60hrs
...

is repeated five times in the list in the app. Here is the relevant code:

class IconicAdapter extends ArrayAdapter<Long> {
private ArrayList<Long> items;
private FakeIDO ido;

public IconicAdapter(Context context,int textViewResourceId, ArrayList<Long> ids, FakeIDO ido){
    super(WorkList.this, R.layout.feed_list, ids);
    this.items = ids;
    this.ido = ido;
}


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);
    }
    for(long id : items){ 
        TextView tt = (TextView) v.findViewById(R.id.toptext);
        TextView bt = (TextView) v.findViewById(R.id.bottomtext);
        if (tt != null) {
              tt.setText(ido.getName(id) + "'s work for " + ido.getOrganization(id));
        }
        if(bt != null){
              bt.setText( ido.totalWorked(id) + "hrs of " + ido.estimatedHours(id) + "hrs");
        }
    }
    return v;
}

Here is the xml view this class is working off of:

<?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="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
    android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_marginRight="6dip"
    android:src="@drawable/icon" />
<LinearLayout
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/toptext"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center_vertical"
    />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" 
        android:id="@+id/bottomtext"
        android:singleLine="true"
        android:ellipsize="marquee"
    />
</LinearLayout>

Now, I understand that the same instance is being returned when I call “TextView tt = (TextView) v.findViewById(R.id.toptext);”, but I don’t know what to change to get a new instance object each time. What am I missing?

  • 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-08T16:06:04+00:00Added an answer on June 8, 2026 at 4:06 pm

    use your getView like this

       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);
        }
    
            TextView tt = (TextView) v.findViewById(R.id.toptext);
            TextView bt = (TextView) v.findViewById(R.id.bottomtext);
            // get the 'id' for position.
            int id = items.get(position);
            if (tt != null) {
                  tt.setText(ido.getName(id) + "'s work for " + ido.getOrganization(id));
            }
            if(bt != null){
                  bt.setText( ido.totalWorked(id) + "hrs of " + ido.estimatedHours(id) + "hrs");
            }
    
        return v;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a list view which as TextView that can display
I'm trying to create a custom ListView layout similar to android.R.layout.simple_list_item_2. However, when I
I'm trying to create a simple list application for my first app. I have
recently I been trying to create an android app that uses JSON Objects to
I am a newbie to android development. I am trying to create a List
I'm trying to create a vertical list of TextView -> EditTextView. I need this
Hi am trying to create a android app with a sql database and i
I am trying to create a list where I want users to enter data
I'm trying to create a list of permutations of a list, such that, for
I'm trying to create UL list with images and descriptions. With 5 items 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.