title: Android Spinner selected item not showing
body: <p>i got the items from the database</p>
  
  <p>Here's the java code</p>
  
  <pre><code>package com.example.androidtablayout;
  
  public class Leave extends Activity implements OnItemSelectedListener{
  Button btnSubmitLeave,btnLogout;
  SessionManager session;
  JSONParser jsonParser = new JSONParser();
  Spinner mySpinner;
  ProgressDialog mProgressDialog;
  JSONArray jsonarray;
  
  ArrayList&lt;String&gt; leavetype;
  String username;
  EditText inputStart,inputEnd,inputReason;
  final Calendar myCalendar = Calendar.getInstance();
  
  private String url_leavetype = "http://10.0.3.2/sunshine-ems/get_leavetype.php";
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.leave);
  
      // CHECK TO LOGIN SESSION
      session = new SessionManager(getApplicationContext());
      session.checkLogin();
      username = session.getUsername();
  
  
      inputReason = (EditText) findViewById(R.id.inputReason);
      inputStart = (EditText) findViewById(R.id.inputStart);
      inputEnd = (EditText) findViewById(R.id.inputEnd);
      btnSubmitLeave = (Button) findViewById(R.id.btnSubmitLeave);
  
  
      //spinner
      mySpinner= (Spinner) findViewById(R.id.spinnerLeaveType);
      leavetype = new ArrayList&lt;String&gt;();
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_spinner_item, leavetype);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      new getLeaveTypes().execute();
      mySpinner.setAdapter(adapter);
      mySpinner.setOnItemSelectedListener(this);
  
  }
  private class getLeaveTypes extends AsyncTask&lt;String, String, String&gt; {
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          mProgressDialog = new ProgressDialog(Leave.this);
          mProgressDialog.setTitle("Getting Leave types");
          mProgressDialog.setMessage("Loading...");
          mProgressDialog.setIndeterminate(false);
          mProgressDialog.show();
      }
  
      @Override
      protected String doInBackground(String... args) {
  
          int success;
  
          List&lt;NameValuePair&gt; params1 = new ArrayList&lt;NameValuePair&gt;();           
          try {
  
              params1.add(new BasicNameValuePair("username", username));          
              JSONObject json = jsonParser.makeHttpRequest(url_leavetype, "GET",params1);
  
              // full json response
              Log.d("Get Leave types", json.toString());
  
              // json success element
              success = json.getInt(TAG_SUCCESS);
              if (success == 1) {
  
                  JSONArray type = json.getJSONArray("leavetypes");                        
  
                  for (int i = 0; i &lt; type.length(); i++) {
                      JSONObject catObj = (JSONObject) type.get(i);
                      leavetype.add(catObj.optString("leave_name"));
                  }
  
              } else {
                  Log.d("Login Failure!", json.getString(TAG_MESSAGE));
                  return json.getString(TAG_MESSAGE);
  
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  
      protected void onPostExecute(String file_url) {
          // dismiss the dialog once product deleted
          mProgressDialog.dismiss();
      }
  
  }
  
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position,
          long id) {
      Toast.makeText(
              getApplicationContext(),
                      parent.getItemAtPosition(position).toString() + " Selected" ,
              Toast.LENGTH_LONG).show();
  
  }
  
  
  public void onNothingSelected(AdapterView&lt;?&gt; arg0) {      
  }
  }
  </code></pre>
  
  <p>That data from the database is there, the spinner list is showing, but when i clicked an item, it's not showing on that spinner.
  I hope someone canhelp me here. Thank you</p>