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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:28:27+00:00 2026-06-01T15:28:27+00:00

While I am well aware that it isn’t possible for me to refer to

  • 0

While I am well aware that it isn’t possible for me to refer to a non-final variable inside my onClick method, I am interested in knowing how I solve the problem I am currently faced with.

I have an ArrayAdapter. If a user presses the checkbox an AsyncTask and the user either subscribes or unsubscribes himself to a queue, depending on whether the checkbox is checked or not.

I want this status to be reflected in each item in the text of my txtStatus TextView. How do I set the text of a TextView depending on the status of a Checkbox?

Here is part of the code from my getView method :

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

    final CheckBox queueCBox;
    userControl = new UserController(context);
    final String queueName = data[position].label; 
    if(row == null)
    {
        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);

        final QueueHolder holder = new QueueHolder();
        holder.queuecbox = (CheckBox)row.findViewById(R.id.queues_item_checkbox);
        queueCBox = (CheckBox)row.findViewById(R.id.queues_item_checkbox);
        holder.txtLabel = (TextView)row.findViewById(R.id.queues_item_label);
        holder.txtStatus = (TextView)row.findViewById(R.id.queues_item_status);

        holder.queuecbox.setOnClickListener(new OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                final String[] param = new String[1];
                param[0] = queueName;

                if(queueCBox.isChecked())
                {
                    holder.txtStatus.setText("Tilmeldt");
                    Log.d("ClickTest","SWITCH ON");
                    new JoinQueueTask().execute(param);


                }   
                else
                {
                    holder.txtStatus.setText("Frameldt");
                    Log.d("ClickTest","SWITCH OFF");
                    new LeaveQueueTask().execute(param);
                }   
            }
        });
        row.setTag(holder);
    }
    else
    {
        final QueueHolder holder = (QueueHolder)row.getTag();
    }

    QueueItem queue = data[position];
    String name = queue.label.replace("-", " "); 
    holder.txtLabel.setText(name);    // holder cannot be resolved
    holder.queuecbox.setChecked(queue.value);  // holder cannot be resolved

    return row;
}
  • 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-01T15:28:28+00:00Added an answer on June 1, 2026 at 3:28 pm

    Keep your holder the way it is. Just for setting the onClickListener, try doing this,

    QueueHolder holder = null;
    if(row == null)
    {
        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
    
        holder = new QueueHolder();
        holder.queuecbox = (CheckBox)row.findViewById(R.id.queues_item_checkbox);
        queueCBox = (CheckBox)row.findViewById(R.id.queues_item_checkbox);
        holder.txtLabel = (TextView)row.findViewById(R.id.queues_item_label);
        holder.txtStatus = (TextView)row.findViewById(R.id.queues_item_status);
        row.setTag(holder);
    }
    else
    {
        holder = (QueueHolder)row.getTag();
    }
    
    QueueItem queue = data[position];
    String name = queue.label.replace("-", " "); 
    holder.txtLabel.setText(name);    // holder cannot be resolved
    holder.queuecbox.setChecked(queue.value);  // holder cannot be resolved
    
    final QueueHolder fianlHolder = holder;
    
    finalHolder.queuecbox.setOnClickListener(new OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                final String[] param = new String[1];
                param[0] = queueName;
    
                if(queueCBox.isChecked())
                {
                    finalHolder.txtStatus.setText("Tilmeldt");
                    Log.d("ClickTest","SWITCH ON");
                    new JoinQueueTask().execute(param);
    
    
                }   
                else
                {
                    finalHolder.txtStatus.setText("Frameldt");
                    Log.d("ClickTest","SWITCH OFF");
                    new LeaveQueueTask().execute(param);
                }   
            }
        });
    return row;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an iPhone app that's location aware (well, I'd LIKE it to be!
I'm well aware that in C++ int someValue = i++; array[i++] = otherValue; has
Is it possible to have transport security without authentication? I'm well aware of it's
I'm trying to fetch list of files using a method that apparently works well
I have been using LinqToSQL for quite a while as well as using Devart,
I have seen this answer https://stackoverflow.com/a/9243472/563381 And while it works well visual as soon
While HTML Scraping is pretty well-documented from what I can see, and I understand
Well after a while of scratching my head and going huh? trying to figure
This popped-up while writing a script for vim. Using the well-documented ':normal' command: :normal
I've been doing a little JavaScript (well, more like jQuery) for a while now

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.