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

  • Home
  • SEARCH
  • 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 8895565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:48+00:00 2026-06-14T23:48:48+00:00

How to make the spinner send a different value other the value specified: For

  • 0

How to make the spinner send a different value other the value specified:

For eg. My strings.xml has the following thing:

<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <string name="app_name">My First App</string>
    <string name="edit_message">Search the Movie Title</string>
    <string name="button_send">Search</string>
    <string name="menu_settings">Settings</string>
    <string name="title_activity_main">MainActivity</string>

    <string-array name="title_type">
        <item>All Types</item>
        <item>Feature Film</item>
        <item>TV Series</item>
        <item>Video Game</item>
    </string-array>
</resources>

now, when the user clicks on All Types, instead of All Types, i need alltypes to been sent. The reason being i need to construct a URL which accepts “alltypes” to fetch data.

I have my MainActivity.java code as:

public class MainActivity extends Activity {

private Button btn;
private EditText edit;
private Spinner spinner;
private TextView textView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btn = (Button) findViewById(R.id.button);
    edit = (EditText) findViewById(R.id.edit_message);
    spinner = (Spinner) findViewById(R.id.spinner);
    textView = (TextView) findViewById(R.id.textView1);

    btn.setOnClickListener(
            new View.OnClickListener()
            {
                public void onClick(View view)
                {
                    //Log.v("EditText", edit.getText().toString());
                    //Log.v("Spinner", spinner.getSelectedItem().toString());
                    //if(spinner.getSelectedItem().toString()=="All Types")

                    String url="http://cs-server.xxx.edu:23405/examples/servlet/HelloWorldExample?title="+edit.getText().toString()+"&type="+spinner.getSelectedItem().toString();
                    Log.v("url",url);
                }
            });



ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.title_type,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

 //String url="http://cs-server.xxx.edu:23405/examples/servlet/HelloWorldExample?tit  le="+edit.getText().toString()+"&type="+spinner.getSelectedItem().toString();
  // Log.v("url",url);

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
        //Object item = parent.getItemAtPosition(pos);

    }
    public void onNothingSelected(AdapterView<?> parent) {
    }
});


}

private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... urls) {
      String response = "";
      for (String url : urls) {
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        try {
          HttpResponse execute = client.execute(httpGet);
          InputStream content = execute.getEntity().getContent();

          BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
          String s = "";
          while ((s = buffer.readLine()) != null) {
            response += s;
          }

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      return response;
    }

    @Override
    protected void onPostExecute(String result) {
      textView.setText(result);
    }
  }

  public void readWebpage(View view) {
    DownloadWebPageTask task = new DownloadWebPageTask();
    task.execute(new String[] { "http://facebook.com"});

  }
} 

I am fairly new to Android Programming.
Any suggestions as to how to do it?

  • 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-14T23:48:49+00:00Added an answer on June 14, 2026 at 11:48 pm
     yourspinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    
                public void onItemSelected(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) 
                {
                    String selecteditem = yourspinner.getSelectedItem().toString();
                    selecteditem = selecteditem.equals("All Types")?selecteditem..replaceAll(" ", "").toLowerCase():selecteditem;
                   // removes the space and converts to lowercase
                }
    
                public void onNothingSelected(AdapterView<?> arg0) {
                    // TODO Auto-generated method stub
    
                }
            });
    

    2nd Option.

     String[] customarr = {"feature,tv_series,game","feature","tv_series","game"};
     String selecteditem = customarr[yourspinner.getSelectedItemPosition()]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Spinner : Spinner spinner = (Spinner)findViewById(R.id.sp1); and I initially make
How to make spinner to fill empty place in left side? android:layout_width=fill_parent does not
When I make the spinner with very long text, the spinner button (not drop
Make it on Linux. The reason to use more than one version of Vim,
I make a bot program and i want to send some keyboard keys between
How would i make what i selected in the spinner appear in a textview
I'm trying to make a loading overlay thing. Currently, I have some javascript adding
I want to make a spinner controll in my page,I tried it like this:
I'm new in iPhone development, and I want to make a custom Reel/Spinner like
In my application, I have a Spinner whose onItemSelected initializes the value of 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.