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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:00:54+00:00 2026-05-31T18:00:54+00:00

While I realize that this question has been asked once or twice ago but

  • 0

While I realize that this question has been asked once or twice ago but I still don’t have a clue how I am supposed to fix the problem with creating a listener for each of my checkboxpreferences.

Any suggestions as to how I solve this problem?

private void setQueuePreferences(JSONObject[] qInfo) 
{
    PreferenceCategory QueueCategory = (PreferenceCategory)findPreference("category_queues");
    CheckBoxPreference[] cbox_queues = new CheckBoxPreference[qInfo.length];

    for(int i = 0; i < qInfo.length; i++)
    {
        cbox_queues[i] = new CheckBoxPreference(this);
        cbox_queues[i].setKey("queue_" + i);

        // Formatting the queue title
        String name = qInfo[i].optString("name").replace("-", " ");
        cbox_queues[i].setTitle(name);

        if(qInfo[i].optString("active").contentEquals("1"))
            cbox_queues[i].setChecked(true);
        else
            cbox_queues[i].setChecked(false);

        QueueCategory.addPreference(cbox_queues[i]);
        cbox_queues[i].setOnPreferenceClickListener(new OnPreferenceClickListener()
        {

            public boolean onPreferenceClick(Preference preference) 
            {
                final String[] param = new String[1];
                param[0] = qInfo[i].optString("name");

                if(cbox_queues[i].isChecked())
                {   
                    new JoinQueueTask().execute(param);
                }
                else
                    new LeaveQueueTask().execute(param);
            }

        });
    }
}
  • 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-31T18:00:55+00:00Added an answer on May 31, 2026 at 6:00 pm

    You can mark an array as final and still change the elements inside it. You can’t however assign a different array to that variable.

    As for the i variable, you can just create a new final int inside the loop like this:

    final int ii = i;
    

    and use that one instead.

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

Sidebar

Related Questions

I realize that this question has been asked and has been answered here but
I realize this question has been asked dozens of times https://stackoverflow.com/search?q=maxStringContentLength However, I still
I realize this question has been asked several times in several different forms ,
I realise this question has been asked 100 times, but i've looked through the
A while ago I asked this question where I was taught to make the
While developing my app I have come to realize that the majority of my
First up, i realize this application has some design issues and while rewriting a
I have looked everywhere for the answer to this question and while there are
I have a multi-part, possibly confusing question... it's been a while since I've dug
I realize there's already been several questions like this, but I think my case

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.