title: How do I allow a function to be called when two spinners equal specific strings?
body: <p>I have made 2 spinners, which both consist of an array of different types of weight. These are "lbs" "Stone" "Grams" "Kilograms". I need to be able to check the options the user has picked from these 2 spinners and then call a function depending on what they chose. So for example if the first spinner equals "Lbs" and the second equals "Grams", then a function will be called.</p>
  
  <p>These are my strings</p>
  
  <pre><code>  &lt;string-array name="weightFSpinner"&gt;
      &lt;item&gt;Lbs&lt;/item&gt;
      &lt;item&gt;Grams&lt;/item&gt;
      &lt;item&gt;Kilograms&lt;/item&gt;
      &lt;item&gt;Stone&lt;/item&gt;
      &lt;item&gt;Ounces&lt;/item&gt;
  &lt;/string-array&gt;
  
  &lt;string-array name="weightSSpinner"&gt;
      &lt;item&gt;Lbs&lt;/item&gt;
      &lt;item&gt;Grams&lt;/item&gt;
      &lt;item&gt;Kilograms&lt;/item&gt;
      &lt;item&gt;Stone&lt;/item&gt;
      &lt;item&gt;Ounces&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p>And this is the code on my weight page</p>
  
  <pre><code>     protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_weight_page);
          // Code for first drop down list
          final Spinner weightFSpinner = (Spinner) findViewById(R.id.weightFSpinner);
          final ArrayAdapter&lt;String&gt; myAdapter = new ArrayAdapter&lt;String&gt;(weightPage.this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.weightFSpinner));
          myAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          weightFSpinner.setAdapter(myAdapter);
  
  
          // code for second drop down list
          final Spinner weightSSpinner = (Spinner) findViewById(R.id.weightSSpinner);
          final ArrayAdapter&lt;String&gt; myAdapter2 = new ArrayAdapter&lt;String&gt;(weightPage.this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.weightSSpinner));
          myAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          weightSSpinner.setAdapter(myAdapter2);
  
  
  
          Button convertBtn = (Button) findViewById(R.id.convertBtn);
          convertBtn.setOnClickListener(new View.OnClickListener() {
  
              //when the button is pressed this happens
              @Override
              public void onClick(View view) {
  
                  if(myAdapter.equals("Lbs") &amp;&amp; myAdapter2.equals("Grams")){
                      poundsToGrams();
                  }
  
  
              }
  
              //converting pounds to grams
              private void poundsToGrams() {
                  EditText convertTxt = (EditText) findViewById(R.id.convertTxt);
                  TextView resultTxt = (TextView) findViewById(R.id.resultTxt);
                  String firstWeight;
                  String secondWeight;
                  double pounds;
  
                  try {
                      pounds = parseDouble(convertTxt.getText().toString());
  
                  } catch
                          (NumberFormatException ex) {
                      convertTxt.setError("Must be int");
                      return;
                  }
                  double result = (pounds * 453.59237);
                  resultTxt.setText(result + " Grams");
              }
  
  
              // firstWeight = myAdapter.getItem(0);
              //secondWeight = myAdapter2.getItem(1);
  
  
          });
      }
  }
  </code></pre>