title: How to set selected Items from a spinner as a default value in Android?
body: <p>This is my code. If I click "14 " then in a spinner should be set as a default value as 14, and if I changed "20" or some values like "16" it should set as a default value in a Spinner. </p>
  
  <p>So selected value must be displayed in a Spinner.</p>
  
  <pre><code> Spinner font=new Spinner(con);
   option= new String[] {"Select","14","16","18","20"};
   ArrayAdapter&lt;String&gt; adapter= new ArrayAdapter&lt;String&gt;(con,android.R.layout.simple_spinner_dropdown_item,option);
   adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   font.setOnItemSelectedListener(new OnItemSelectedListener() {
  
   public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,int position, long id) {
   if(!(arg0).getSelectedItem().toString().trim().equalsIgnoreCase("Select"))
   size=Float.parseFloat((option[(arg0).getSelectedItemPosition()]).trim());
         }
   public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
              // TODO Auto-generated method stub
  
          }
      });
   font.setAdapter(adapter);
   int i;
   for( i=0;i&lt;option.length;i++){
  
   if(option[i].toString().equalsIgnoreCase("14")){
    }
   else  {
   font.setSelection(i);
          }
  
       }
  </code></pre>