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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:18:35+00:00 2026-06-07T11:18:35+00:00

I have been working on this all night and I am in a brain

  • 0

I have been working on this all night and I am in a brain fog. can anyone give me a code snipit that would help I currently have this to populate SpinnerA onCreate:

ArrayAdapter<CharSequence> adapterTypeGas = ArrayAdapter.createFromResource(
this, R.array.TypeGas, android.R.layout.simple_spinner_item);
adapterTypeGas.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTypeGas.setAdapter(adapterTypeGas);

R.array.TypeGas has two choices “Propane Gas” or “Natural Gas”. depending on what the user selects I want SpinnerB to use either R.array.NaturalGas or R.array.PropaneGas. My problem is that the spinner is populated at create how do I change it so it is not populated until after SpinnerA onItemSelected? Thanks for your help. I am fairly new to developing so if you could be detailed in your answer that would be great.

after implementing the code from “RastheDestoryer” i get an error at “createFromResource” of the ArrayAdapter for spinnerB. the error is: The method createFromResource(Context, int, int) in the type ArrayAdapter is not applicable for the arguments (CSSTPipeSizingActivity.OnGasSelectedListener, int, int). In my main.xml file I have to specify an array for spinnerB (that array is stored in my strings.xml file) uses. I think this is the problem, because in my code I am telling it a different array. Any thoughts on how to resolve this?

  • 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-07T11:18:39+00:00Added an answer on June 7, 2026 at 11:18 am

    This is the code that I ended up using:

    public void main program () {
    ...
    ArrayAdapter<CharSequence> adapterTypeGas = ArrayAdapter.createFromResource(
                this, R.array.TypeGas, android.R.layout.simple_spinner_item);
            adapterTypeGas.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerTypeGas.setAdapter(adapterTypeGas);
    
        //Sets up the spinnerPipeLength spinner 
        ArrayAdapter<CharSequence> adapterPipeLength = ArrayAdapter.createFromResource(
                this, R.array.PipeLength, android.R.layout.simple_spinner_item);
            adapterPipeLength.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerPipeLength.setAdapter(adapterPipeLength);
    
        // Listens for changes in the selected item in each spinner 
        spinnerTypeGas.setOnItemSelectedListener(new GASOnItemSelectedListener());
        spinnerSupplyPressure.setOnItemSelectedListener(new    SupplyOnItemSelectedListener());
        spinnerPipeLength.setOnItemSelectedListener(new MyOnItemSelectedListener());
    ...
    } // end mainprogram()
    
    public void SpinnerNatGas() {
        ArrayAdapter<CharSequence> adapterSupplyPressure = ArrayAdapter.createFromResource(
                this, R.array.NaturalGas, android.R.layout.simple_spinner_item);
        adapterSupplyPressure.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerSupplyPressure.setAdapter(adapterSupplyPressure);
        adapterSupplyPressure.notifyDataSetChanged();
    } // end SpinnerNatGAs ()
    
    public void SpinnerProGas () {
        ArrayAdapter<CharSequence> adapterSupplyPressure = ArrayAdapter.createFromResource(
                this, R.array.PropaneGas, android.R.layout.simple_spinner_item);
        adapterSupplyPressure.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerSupplyPressure.setAdapter(adapterSupplyPressure);
        adapterSupplyPressure.notifyDataSetChanged();
    } // end SpinnerProGAs ()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working all night and yesterday on this header section in css,
Ok, I'm totally baffled. I've been working on this all night and I can't
I have been working on this all day, much of my code is from
I have been working on this all day with no luck. Its night now
I have been searching all night for an answer to this but can't seem
I have been working on this application that enables user to log in into
I've been working at this all morning and I still can't find a way
So I have been wrestling with this issue all night..... I essentialls have my
I have been working on this for hours, and I just can't figure it
I have been staring at this all night now. I am trying to make

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.