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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:22:28+00:00 2026-05-25T16:22:28+00:00

How to update an ArrayAdapter with my new array? Belwo is my ArrayAdapter with

  • 0

How to update an ArrayAdapter with my new array?

Belwo is my ArrayAdapter with a default array added to it.

String[] array_spinner = new String[]{"Select your state."};
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,android.R.layout.simple_spinner_item,array_spinner);
adapter.setDropDownViewResource(R.layout.state_spinner_layout);
Myspinner.setAdapter(adapter);

Now I load some JSON data that parses the info into the array_spinner_data and I want to call notifyDataSetChanged()

array_spinner = new String[]jsonArray.length(); 


        for (int i=0; i<jsonArray.length(); i++)
        {   
            String styleValue = jsonArray.getJSONArray(i).getString(0);    
            Log.d(TAG, styleValue);
            array_spinner[i] = styleValue;

        }
        Log.d(TAG, String.valueOf(array_spinner.length));
        adapter.notifyDataSetChanged();

I am not seeing any errors and all of my Log.d are coming back as they should. But when I click my spinner all that is showing is the original Select your state I left out some of the basic onCreate and Json load stuff but if anyone needs to see it just let me know.

  • 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-25T16:22:28+00:00Added an answer on May 25, 2026 at 4:22 pm

    notifyDataSetChanged is “not working” because you are not changing the data set, you are creating a new copy, one that the adapter has no knowledge about. Use a List<> instead of an array, and modify that same list object that you passed to your adapter and it will work. If you want to keep your current code, then you have to create a new adapter over the new data set and apply it to your spinner.

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

Sidebar

Related Questions

UPDATE: In trying to replicate this problem one more time to answer your questions
I have a listview with a custom array adapter: public class SmsMessageAdapter extends ArrayAdapter<ContactMessage>
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update: Please read this question in the context of design principles, elegance, expression of
I have an Android ListView, backed by an ArrayAdapter. When the user clicks on
Here is my ArrayAdapter. I would like to make this more efficient by following
Update : this is more-or-less a dupe , and it turns out to be
UPDATE - No need to answer this now, I have solved below. Hi, I'm

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.