How do I get the data of a returned value from a spinner?

Amren

I am making an android application that asks a user to enter the name of a code and then the actual code itself. Once the user inputs these values and presses a submit button the inputs are passed to another class that stores them. For this so far I have used (with the unnecessary bits in between omitted):

EditText nameCode, dataCode;

nameCode = (EditText) findViewById(R.id.codeName);                                      
dataCode = (EditText) findViewById(R.id.codeData);

spinner = (Spinner) findViewById(R.id.ticketType);                                                                                  
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.codeType, android.R.layout.simple_spinner_dropdown_item);      
spinner.setAdapter(adapter);

final Button addBtn = (Button) findViewById(R.id.submitbtn);                           
addBtn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        addPassCode(nameCode.getText().toString(),dataCode.getText().toString());      
        populateCodes();                                                                
    }
});

private void addPassCode(String name, String passCode) {
    PassCodes.add(new PassCode(name, passCode));

This part all works fine. What I am trying to do is now pass another variable as well as 'name' and 'passCode' in my addPassCode method. I have a spinner that contains an array of 3 values (Strings) and I want the user to select a value and then the equivalent of getText().toString() for a spinner input so I can add it to my method to pass it to my class 'PassCodes' storing all the data. Also how would i cast this variable similarly to the previous 2 to EditText?

Also what would be the correct variable type for ticketType?

ucsunil

You can simply do the following:

String text = spinner.getSelectedItem().toString();

And then to set the value in your EditText, simply do:

dataCode.setText(text);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to do i get returned data from ajax call

From Dev

How do I get a value from a selected Spinner item that loads a ListPreference?

From Dev

pthread_create(), how do I get the returned value from the passed function

From Dev

pthread_create(), how do I get the returned value from the passed function

From Dev

How do I get the selected text from custom spinner?

From Dev

How can i get data from json to spinner?

From Dev

How do i get the value of first index in a returned List of array

From Dev

How do I concatenate a string with a value returned from a mule expression?

From Dev

BASH: How do i store the value returned from a website into a varuable

From Dev

How can i get a value returned by doInBackground() from AsyncTask class

From Dev

How do I get the returned entity from a entitydatasource binding to a detailsview?

From Dev

How do I get the values of the model returned from Controller in ajax?

From Dev

How to get list of data from database to spinner

From Dev

How do I get value from tags?

From Dev

How can i get the ID selected from my spinner with data from mysql

From Dev

AngularJS : How to get returned value from factory

From Dev

how I can change the value of the button depending on Spinner which takes the data from the database in Android?

From Dev

How do I set spinner value based on the value in preferences

From Dev

How do I set spinner value based on the value in preferences

From Dev

How do i get the specific value from json data using Angularjs

From Dev

How do I get the Selected Item Value from Data Grid Combo Box Column

From Dev

How do I get the value from a data-selected input option?

From Dev

How do i get the specific value from json data using Angularjs

From Dev

Spinner from database - get value

From Dev

How do I access the returned value from a Web API Method in Android?

From Dev

How do I use a value that is returned from a Macro Variable in another macro

From Dev

How do I use a value returned from a wxPython button in another function?

From Dev

How do I extract a specific value from a JSON returned object with javascript?

From Dev

How do I use a value that is returned from a Macro Variable in another macro

Related Related

  1. 1

    how to do i get returned data from ajax call

  2. 2

    How do I get a value from a selected Spinner item that loads a ListPreference?

  3. 3

    pthread_create(), how do I get the returned value from the passed function

  4. 4

    pthread_create(), how do I get the returned value from the passed function

  5. 5

    How do I get the selected text from custom spinner?

  6. 6

    How can i get data from json to spinner?

  7. 7

    How do i get the value of first index in a returned List of array

  8. 8

    How do I concatenate a string with a value returned from a mule expression?

  9. 9

    BASH: How do i store the value returned from a website into a varuable

  10. 10

    How can i get a value returned by doInBackground() from AsyncTask class

  11. 11

    How do I get the returned entity from a entitydatasource binding to a detailsview?

  12. 12

    How do I get the values of the model returned from Controller in ajax?

  13. 13

    How to get list of data from database to spinner

  14. 14

    How do I get value from tags?

  15. 15

    How can i get the ID selected from my spinner with data from mysql

  16. 16

    AngularJS : How to get returned value from factory

  17. 17

    how I can change the value of the button depending on Spinner which takes the data from the database in Android?

  18. 18

    How do I set spinner value based on the value in preferences

  19. 19

    How do I set spinner value based on the value in preferences

  20. 20

    How do i get the specific value from json data using Angularjs

  21. 21

    How do I get the Selected Item Value from Data Grid Combo Box Column

  22. 22

    How do I get the value from a data-selected input option?

  23. 23

    How do i get the specific value from json data using Angularjs

  24. 24

    Spinner from database - get value

  25. 25

    How do I access the returned value from a Web API Method in Android?

  26. 26

    How do I use a value that is returned from a Macro Variable in another macro

  27. 27

    How do I use a value returned from a wxPython button in another function?

  28. 28

    How do I extract a specific value from a JSON returned object with javascript?

  29. 29

    How do I use a value that is returned from a Macro Variable in another macro

HotTag

Archive