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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:28:13+00:00 2026-05-24T06:28:13+00:00

I am trying to update the textview in my gallery after it has been

  • 0

I am trying to update the textview in my gallery after it has been created using my updateCaption method, however, only the first textview in the gallery gets updated. When I print out my textview, they all have the same ID like android.widget.TextView@40942d60.

public class ImageAdapter extends BaseAdapter {

    private static LayoutInflater inflater = null;
    private int[] image;
    private TextView caption;

    public ImageAdapter(Context context) {
        inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        image = new int[4];

        for (int i = 0; i < image.length; i++)
        {
              image[i] = R.drawable.image;
        }
    }

    public void updateCaption(String text, int position)
    {
        System.out.println(position + ": text");
        caption.setText(text);

        System.out.println(caption);
    }

    public int getCount() {
        return image.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public static class ViewHolder{
        public TextView text, dssnum, scnum;
        public ImageView image;
    }

    public View getView(int position, View convertView, ViewGroup parent) 
    {
        View vi = convertView;
        ViewHolder holder;

        if (convertView == null)
        {
            vi = inflater.inflate(R.layout.caption, null);
            holder = new ViewHolder();
            caption = holder.text = (TextView) vi.findViewById(R.id.textView1);
            holder.scnum = (TextView) vi.findViewById(R.id.scnum);
            holder.dssnum = (TextView) vi.findViewById(R.id.dss_num);
            holder.image = (ImageView) vi.findViewById(R.id.image);
            vi.setTag(holder);
        }
        else
            holder = (ViewHolder) vi.getTag();


        holder.dssnum.setText("Unavailable");

        holder.image.setImageResource(image[position]);
        holder.text.setText("Not available.");
        return vi;
    }
}

Does anyone know what I am doing wrong?

Added: how I am using updateCaption

for (int j = 0; j < listOfList.get(i).size(); j++)
{
        galleryImageAdapter.updateCaption("test " + j, j);
 }
  • 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-24T06:28:14+00:00Added an answer on May 24, 2026 at 6:28 am

    I think this is due to this line…

    caption = holder.text = (TextView) vi.findViewById(R.id.textView1);
    

    once all convertView is created, your caption will always point to the textview of the last convertView.

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

Sidebar

Related Questions

I have been trying to update a TextView field, when i Tap on the
I've been trying the following to get the textview to update on any changes
Im trying to update the contents of an element after running some php code.
I'm trying to update my custom ArrayAdapter, but after calling updateListArray getView is called
I am trying to update my status using SSO and with an onClickListener on
I am trying to schedule a task to update a TextView once a second.
I am trying to update a TextView which will show the system volume. I
I am trying update my table from c# ado.net with this function.I am using
I'm trying to update the TextView within a custom ListView at a set time
Hello I am trying to update the textview at every certain time, but it

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.