java - Call a spinner's value? Also, use other values based on a spinner's value -


I have a spinner 'aperture' which creates a list of numbers, and a spinner with two options 'mode' is. When a button is pushed, then I need to compute to use different inputs with the 'Aperture' from the current selection and the value received from 'mode'. How do I call the value of the spinner so that I can use it in calculation?

In addition, how do I select spinner mode to set this other value before using it in the calculator? To be more specific, if the spinner is set to small, then the value I use in the calculation is 0.015, whereas if big is selected then I need to use 0.028

My other Input editing is test view, so I have just been set up like this:

  input = (edit text) findViewById (R.id.input1); Input2 = (Edit Text) Search ViviBid (RID.Inline2); Input 3 = (edit text) Find VVBIID (RID.quarter3); Input4 = (EditText) findViewById (R.id.input4); Find Output = (TextView) VVBIID (RID Reset); Output2 = (TextView) findViewById (R.id.result2); // Aperture Dropdown Spinner S = (Spinner) Find VViBiID (R.D.Ept); ArrayAdapter adapter2 = ArrayAdapter.createFromResource (this, R.array.apertures, android.R.layout.simple_spinary_item); Adapter2.setDropDownViewResource (android.R.layout.simple_spinner_dropdown_item); S.setAdapter (adapter2); // button last button button = (button) Find VVBIID (RID calculate); Button.setOnClickListener (New View.OnClickListener () {public void onClick (see v) {// action on} click doCalculation ();}}); } Private zero doCalculation () {// entered input value string strValue = input.getText (). ToString (); String strValue2 = input2.getText (). ToString (); String strValue3 = input3.getText (). ToString (); String strValue4 = input4.getText () ToString (); // a hard-coded calculation double imperial 1 = (double .pda double (strue 3) + (double. Stravalue4 / 12)); Double number = integer.parseant (strue) * 2; Dual number 2 = ((number / 20) + 3) / integer Parcietic (strue 2); // Update UI with Result Output. Set Text ("Result:" + number); Output2.setText ("Result 2:" + Imperial 1); }}  

This is not a real equation, to ensure that there is only one test that everything is properly connected. How do I call the value of Spinner Aperture and Small / Large Spinner 'Mode'

The value of the spinner is appropriate as one of the following:

  object object = spinner.getSelectedItem (); Long id = spinner.getSelectedItemId (); The condition of the int = iTempeosition (); View selected view = getSelectedView ();  

In your case, you can declare the spinner as the last and pass the selected items in the doCalculations () method as follows:

  Find the last spinner aptpin = (spinner) VViBiID (R.D.Ept); ... // Button Last Button Button = (Button) Find VVBIID (RID Calculator); Button.setOnClickListener (new View.OnClickListener () {public void onClick (see v) {// click action on doCalculation (aptSpinner.getSelectedItem ())}}}); } Private Wide Ductalization (object select itam) {...}  

This will probably take you a basic Java book and learn how the task works in Java.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -