title: How to display selected Item in Spinner?
body: <p>I created two Spinners to display the data in my application. In my first Spinner, the first item of the list is always displayed directly, but in the second Spinner nothing is displayed, even if I click on an item on the drop down view. Can anybody explain this behaviour?</p>
  
  <p>Here is the code of the initialisation of the two spinners:</p>
  
  <pre><code>projects = new Spinner(lexs);
  projectAdapter = new ProjectAdapter();
  projects.setAdapter(projectAdapter);
  projects.setMinimumWidth(250);
  projects.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  
  @Override
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
     updateSpinners(position);                    
  }
  
  @Override
  public void onNothingSelected(AdapterView&lt;?&gt; parent) {
     // do nothing    
  }
  
  });
  
  projectsList = new Spinner(lexs);
  projectsList.setMinimumWidth(250);
  listAdapter = new ListAdapter();
  projectsList.setAdapter(listAdapter);
  projectsListLayer.addView(projectsList);
  </code></pre>
  
  <p>The Spinner projects is the first Spinner which works correctly. projectsList is the second Spinner which doesn't work correctly. Here are the two implementations of the adapters:</p>
  
  <pre><code>private class ProjectAdapter implements SpinnerAdapter {
  
          @Override
          public View getDropDownView(int position, View arg1, ViewGroup arg2) {
              TextView text = new TextView(lexs);
              text.setText(allProjects.get(position).getName());
              return text;
          }
  
          @Override
          public int getCount() {
              return allProjects.size();
          }
  
          @Override
          public Object getItem(int position) {
              return allProjects.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          @Override
          public int getItemViewType(int arg0) {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public View getView(int position, View arg1, ViewGroup arg2) {
              TextView text = new TextView(lexs);
              text.setText(allProjects.get(position).getName());
              return text;
          }
  
          @Override
          public int getViewTypeCount() {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public boolean hasStableIds() {
              return false;
          }
  
          @Override
          public boolean isEmpty() {
              if (allProjects.size() == 0) {
                  return true;
              } else {
                  return false;
              }
          }
  
          @Override
          public void registerDataSetObserver(DataSetObserver arg0) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void unregisterDataSetObserver(DataSetObserver observer) {
              // TODO Auto-generated method stub
  
          }
  
      }
  
      private class ListAdapter implements SpinnerAdapter {
  
          @Override
          public View getDropDownView(int position, View view, ViewGroup parent) {
              TextView text = new TextView(lexs);
              text.setText(allLists.get(position).getName());
              return text;
          }
  
          @Override
          public int getCount() {
              return allLists.size();
          }
  
          @Override
          public Object getItem(int position) {
              return allLists.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          @Override
          public int getItemViewType(int position) {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              TextView text = new TextView(lexs);
              text.setText(allLists.get(position).getName());
              return text;
          }
  
          @Override
          public int getViewTypeCount() {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public boolean hasStableIds() {
              // TODO Auto-generated method stub
              return false;
          }
  
          @Override
          public boolean isEmpty() {
              if (allLists.size() == 0) {
                  return true;
              } else {
                  return false;
              }
          }
  
          @Override
          public void registerDataSetObserver(DataSetObserver observer) {
              // TODO Auto-generated method stub
          }
  
          @Override
          public void unregisterDataSetObserver(DataSetObserver observer) {
              // TODO Auto-generated method stub
          }
  
      }
  </code></pre>
  
  <p>Here I attached a picture of the problem:</p>
  
  <p><a href="http://www.freeimagehosting.net/image.php?7684c157b8.png" rel="nofollow noreferrer">http://www.freeimagehosting.net/image.php?7684c157b8.png</a></p>