title: Android spinner within a button onclicklistener
body: <p>I am using a button created programmatically through java file. I am using button onclick listener to represent the functionality. Is it possible to add a spinner inside that button click listener? My Code goes here:</p>
  
  <pre><code>View.OnClickListener newtodobtn = new View.OnClickListener() {
      public void onClick(View v) {
        // it was the 1st button
  
          setContentView(R.layout.main);
  
          sp1 = (Spinner)findViewById(R.id.spinner1);
          ArrayAdapter&lt;?&gt; adapter = ArrayAdapter.createFromResource(this, R.array.priority, R.id.spinner1);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          sp1.setAdapter(adapter);
          sp1.setAdapter(adapter);}
  </code></pre>
  
  <p>If i use this code, i get following error:</p>
  
  <blockquote>
    <p>The method createFromResource(Context, int, int) in the type ArrayAdapter is not applicable for the arguments (new View.OnClickListener(){}, int, int)</p>
  </blockquote>
  
  <p>Any help is appreciated and thanks in advance</p>