title: selecting the first item of the spinner selecting the default value
body: <p>I have a spinner in my app which is supposed to show a list of items. Initially it would be showing a default text and after selection has been made, all the item list will be seen in a drop down menu. The issue with the spinner is, when ever I am selecting the first item, the default value is getting selected. I know for some, it might be an easy question. However, if you are going to downvote, please do suggest an answer before doing that, because I have tried all possible solutions that I can. Below I am posting my code. Please have a look. Thanks in advance.</p>
  
  <pre><code>The spinner Adapter:
  
      public class CustomSpinnerAdapter extends ArrayAdapter&lt;String&gt; {
  
      Context context;
      ArrayList&lt;String&gt; objects;
      String firstElement;
      boolean isFirstTime;
  
      public CustomSpinnerAdapter(Context context, int textViewResourceId, ArrayList&lt;String&gt; objects, String defaultText) {
          super(context, textViewResourceId, objects);
          this.context = context;
          this.objects = objects;
          this.isFirstTime = true;
          setDefaultText(defaultText);
      }
  
      @Override
      public View getDropDownView(int position, View convertView, ViewGroup parent) {
          if(isFirstTime) {
              objects.set(0, firstElement);
              isFirstTime = false;
          }
          return getCustomDropdownView(position, convertView, parent);
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          notifyDataSetChanged();
          return getCustomView(position, convertView, parent);
      }
  
      public void setDefaultText(String defaultText) {
          this.firstElement = objects.get(0);
          objects.set(0,defaultText);
      }
  
      public View getCustomView(int position, View convertView, ViewGroup parent) {
  
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View row = inflater.inflate(R.layout.spinner_row, parent, false);
          TextView label = (TextView) row.findViewById(R.id.spinnerText);
          label.setText(objects.get(position));
  
          return row;
      }
      public View getCustomDropdownView(int position, View convertView, ViewGroup parent) {
  
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View row = inflater.inflate(R.layout.simple_spinner_dropdown_item, parent, false);
          CheckedTextView label = (CheckedTextView) row.findViewById(R.id.text1);
          label.setText(objects.get(position));
  
          return row;
      }
  
  }
  </code></pre>
  
  <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
  
  <pre><code>In the mainactivity:
  
                              CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter((Context)MainActivity.this,
                                  R.layout.spinner_row, dcuName, "Select One DCU");
                          dcuListScheduler.setAdapter(customSpinnerAdapter);
  </code></pre>