title: How to check whether user selected item from spinner in android?
body: <p>I have an activity which contain spinner that has some list of items and I have a button named as "submit",first time submit button becomes disable it will be enable only after user select item from spinner if not selected the submit remain disable,for this I have to make condition on button click .How can I do that
  code:-</p>
  
  <pre><code>m_OperatorSpinner = (Spinner) m_Main.findViewById(R.id.operator_spinner);
      ArrayAdapter&lt;COperatorStorage&gt; adapter = new ArrayAdapter&lt;COperatorStorage&gt;(getActivity(), R.layout.recharge_item, CRechargeOperatorList.item);
      m_OperatorSpinner.setAdapter(adapter);
      m_OperatorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              COperatorStorage operatorName = CRechargeOperatorList.item[position];
              selectedOperatorCode = operatorName.code;
              Log.e(TAG, "Operator code:-" + selectedOperatorCode);
  
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
          }
      });
  public void checkforEmpty() {
      if (NetworkUtil.isConnected(getActivity())) {
          if (m_szMobileNumber.length() == 13) {
              if (m_szAmount.length() != 0) {
                  if (selectedOperatorCode!=null){
                      m_SubmitButton.setEnabled(true);
                      m_SubmitButton.setBackgroundColor(Color.rgb(0, 80, 147));// set background color on eabled
                      m_SubmitButton.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              proceedToRecharge(v);
                          }
                      });
                  }else {
                      m_SubmitButton.setEnabled(false);
                      m_SubmitButton.setBackgroundColor(Color.rgb(192, 192, 192));
                  }
  
              } else {
                  m_SubmitButton.setEnabled(false);
                  m_SubmitButton.setBackgroundColor(Color.rgb(192, 192, 192));
              }
          } else {
              m_SubmitButton.setEnabled(false);
              m_SubmitButton.setBackgroundColor(Color.rgb(192, 192, 192));
          }
      } else {
          try {
              CSnackBar.getInstance().showSnackBarError(m_Main.findViewById(R.id.mainLayout), "No Internet Connection Available", getActivity());
  
          } catch (Exception e) {
              e.printStackTrace();
          }
          m_SubmitButton.setEnabled(false);
          m_SubmitButton.setBackgroundColor(Color.rgb(192, 192, 192));
      }
  }
  </code></pre>