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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:14:37+00:00 2026-05-22T19:14:37+00:00

This is my code […] final String[] top_spinner_items = new String[35]; for (int i

  • 0

This is my code

[...]
final String[] top_spinner_items = new String[35];
for (int i = 0; i < top_spinner_items.length; i++) {
    top_spinner_items[i] = Integer.toString(i+1);
}
ArrayAdapter<String> spn_topItemsAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, top_spinner_items);
spn_topItemsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
[...]



AdapterView.OnItemSelectedListener lst_bottomSpinner_changed_element = new OnItemSelectedListener() {

    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        //
        final String[] top_spinner_items = new String[35];
        for (int i = 0; i < top_spinner_items.length; i++) {
            top_spinner_items[i] = Integer.toString(i+1);
        }
        ArrayAdapter<String> spn_topItemsAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_item, top_spinner_items);
        spn_topItemsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    }

    public void onNothingSelected(AdapterView<?> parentView) {
        // your code here
    }

};

(all the missing references are in the code are between or before the code)

My question is why inside AdapterView.OnItemSelectedListener

ArrayAdapter<String> spn_topItemsAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, top_spinner_items);

gives error. It says “the constructor is undefined”. I tryed using android.widget.ArrayAdapter, but got none.
I’m trying to change the adapter of a spinner when a previous spinner is changed(i want the second spinner to have the value setted in the previous one)

Do you have any idea?

  • 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-22T19:14:38+00:00Added an answer on May 22, 2026 at 7:14 pm

    You got a compile error because you pass an instance of AdapterView.OnItemSelectedListener to the constructor of the adapter instead of context. Modify your code in onItemSelected, adding classname of your Activity before this:

    ArrayAdapter<String> spn_topItemsAdapter = new ArrayAdapter<String>(YourActivity.this,
                android.R.layout.simple_spinner_item, top_spinner_items);
    

    And, you missed setting the adapter to your ListView in inItemSelected, like parentView.setAdapter(spn_topItemsAdapter);.
    However, I think, changing whole adapter in onItemSelected isn’t a good idea. You’d better modify the existing one.

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

Sidebar

Related Questions

This code: <% string path = Request.ApplicationPath.ToString(); %> <link href=<%= path %>/Content/Site.css rel=stylesheet type=text/css
This code URL listofFiles = this.getClass().getResource(someDir); File f = new File(listofFiles.toString()); File[] files =
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code doesn't work: URL url = new URL( xmlPath ); InputSource input =
This code compiles on msvc/g++: class A{ protected: int i; class B{ public: A*
This code: class RawStringIterator { java.util.Stack<State> stateStack = new java.util.Stack<State>(); RawStringIterator(RawStringIterator i) { stateStack
This code does not compile. public class Diamond { public static void diamondOfAsterisks(String *
This code does not return the correct result: Pattern p=Pattern.compile(^[y]{1,4}$|^[m]{1,4}$|^[d]{1,4}$); String text1=yyyy; String text2=mmm;
This code in JS gives me a popup saying i think null is a

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.