title: How to implement Android Spinner from inside a Fragment view
body: <p>I need to implement 3 spinner objects inside of a fragment. However, I am getting the error. I have posted the error message below.</p>
  
  <blockquote>
    <p>setOnItemClickListener 
    (android.widget.AdapterView.OnItemClickListener) in Spinner cannot be
    applied to (anonymous
    android.widget.AdapterView.OnItemSelectedListener)</p>
  </blockquote>
  
  <p><strong>Java Class:</strong></p>
  
  <pre><code>public class RegisterFragment extends Fragment {
  private static final String[] monthPaths = {"January", "February", "March", "April", "May", "June",
                              "July", "August", "September", "October", "November", "December"};
  private static final String[] dayPaths = {"01", "02", "03", "04", "05", "06", "07", "08", "09",
          "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
          "25", "26", "27", "28", "29", "30", "31"};
  private static final String[] yearPaths = {"1917", "1918", "1919", "1920", "1921", "1922",  "1923",
          "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", "1933", "1934",
          "1935", "1936", "1937", "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945",
          "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956",
          "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967",
          "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978",
          "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989",
          "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000",
          "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",
          "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020"};
  private String monthString = null;
  private String dayString = null;
  private String yearString = null;
  
  public RegisterFragment() {
      // Required empty public constructor
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.fragment_sign_up,container,false);
  
      final Spinner spinnerMonth = (Spinner)view.findViewById(R.id.spinner_birth_month);
      final Spinner spinnerDay = (Spinner)view.findViewById(R.id.spinner_birth_day);
      final Spinner spinnerYear = (Spinner)view.findViewById(R.id.spinner_birth_year);
  
      ArrayAdapter&lt;String&gt; monthAdapter = new ArrayAdapter&lt;&gt;(view.getContext(),
              android.R.layout.simple_spinner_item, monthPaths);
      ArrayAdapter&lt;String&gt; dayAdapter = new ArrayAdapter&lt;&gt;(view.getContext(),
              android.R.layout.simple_spinner_item, monthPaths);
      ArrayAdapter&lt;String&gt; yearAdapter = new ArrayAdapter&lt;&gt;(view.getContext(),
              android.R.layout.simple_spinner_item, monthPaths);
  
      monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
      spinnerMonth.setAdapter(monthAdapter);
      spinnerDay.setAdapter(dayAdapter);
      spinnerYear.setAdapter(yearAdapter);
  
      spinnerMonth.setOnItemClickListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                                     int position, long id) {
              monthString = parent.getItemAtPosition(position).toString();
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
          }
      });
  
      spinnerDay.setOnItemClickListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                                     int position, long id) {
              dayString = parent.getItemAtPosition(position).toString();
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
          }
      });
  
      spinnerYear.setOnItemClickListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                                     int position, long id) {
              yearString = parent.getItemAtPosition(position).toString();
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
          }
      });
      return view;
  </code></pre>