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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:42:59+00:00 2026-06-11T07:42:59+00:00

I’ve created three Spinners with certain list of values. I store each Spinner’s selection

  • 0

I’ve created three Spinners with certain list of values. I store each Spinner’s selection value in a variable. The problem is when I go to the next page I lose my variables. What should I do?

public class TabOneActivity extends Activity implements OnItemSelectedListener{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabone);

        // Spinner element
        Spinner spinner = (Spinner) findViewById(R.id.fudtaste);

        // Spinner click listener
        spinner.setOnItemSelectedListener(this);

        // Spinner Drop down elements
        List<String> categories = new ArrayList<String>();
        categories.add("    Chineese");
        categories.add("    Fast Food");
        categories.add("    Traditional");
        categories.add("    Mixed");
        categories.add("    Favourites");
        categories.add("    Combo Items");

        //Toast.makeText(getApplicationContext(),newPos1,Toast.LENGTH_LONG).show();
     //  System.out.println(str + "sarath" );

        Spinner spinner2 = (Spinner) findViewById(R.id.foodmoney);

        // Spinner click listener
        spinner2.setOnItemSelectedListener(this);

        // Spinner Drop down elements
        List<String> categories2 = new ArrayList<String>();
        categories2.add("    Fast Food");
        categories2.add("    Pub Food");
        categories2.add("    High End Food");
//        categories2.add("    ");
//        categories2.add("    Music With Food");
//        categories2.add("    Enjoy The Food");
        int newPos2 = spinner2.getSelectedItemPosition();

        //Toast.makeText(getApplicationContext(),newPos2,Toast.LENGTH_LONG).show();
        System.out.println(newPos2 + "sarath" );

        Spinner spinner3 = (Spinner) findViewById(R.id.transport);

        // Spinner click listener
        spinner3.setOnItemSelectedListener(this);

        // Spinner Drop down elements
        List<String> categories3 = new ArrayList<String>();
        categories3.add("    I'll Walk");
        categories3.add("    A Cab Please");
        categories3.add("    Limo!!");
        int newPos3 = spinner3.getSelectedItemPosition();

        //Toast.makeText(getApplicationContext(),newPos3,Toast.LENGTH_LONG).show();
        System.out.println(newPos3 + "sarath" );

        // Creating adapter for spinner
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
        ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories2);
        ArrayAdapter<String> dataAdapter3 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories3);

        // Drop down layout style - list view with radio button
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dataAdapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        // attaching data adapter to spinner
        spinner.setAdapter(dataAdapter);
        spinner2.setAdapter(dataAdapter2);
        spinner3.setAdapter(dataAdapter3);

        Button bt1 = (Button)findViewById(R.id.search1);
        bt1.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {
                    Intent j = new Intent(getApplicationContext(), PlanMyDayListActivity.class);
                    j.putExtra("tab", 1);

                    startActivity(j);
            }
        });
    }

//  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//      // On selecting a spinner item
//      String item = parent.getItemAtPosition(position).toString();
//      
////         Context mContext = null;
////        Toast.makeText(mContext,item,Toast.LENGTH_SHORT).show();
//      Toast.makeText(getApplicationContext(),item,Toast.LENGTH_LONG).show();
//
//  }
    public void onNothingSelected(AdapterView<?> arg0) {
    }

    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    }
}
  • 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-11T07:43:00+00:00Added an answer on June 11, 2026 at 7:43 am

    try new

    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        TextView tv = (TextView)arg1;
        String str=tv.getText().toString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is

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.