title: get spinner position and use it in button onclick
body: <p>I am trying to make app with one text view, one button and one spinner. I make button work showing random values from string array, but i have a lot different string arrays(list1, list2 etc). Now my question is when change spinner position, how to get button get another string array(from spinner) and show it to textview. 
  How to pass value from spinner when something is selected in spinner to button.
  Any help is appreciated. 
  Here is my code:</p>
  
  <pre><code>public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener {
  
      Button btn;
  
  
      public String[] myString,myString1;
      public static final Random rgenerator = new Random();
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
           //textview
          final TextView tv = (TextView) findViewById(R.id.textureView);
          final Resources res = getResources();
  
  
  
           //string
          myString = res.getStringArray(R.array.World_War_I);
          myString1 = res.getStringArray(R.array.World_War_II);
  
  
  
      //button
          btn = (Button) findViewById(R.id.buttonxx);
          btn.setOnClickListener(new View.OnClickListener(){
              public void onClick (View v){
  
             //i am missing code here, spinner position, and pass spinner position to if statement.
  
                    if (==0){
  
                        myString = res.getStringArray(R.array.list1);
  
                        String q = myString[rgenerator.nextInt(myString.length)];
                        tv.setText(q);
                   }
                    if (==1){
                      myString1 = res.getStringArray(R.array.list2);
  
                       String q1 = myString1[rgenerator.nextInt(myString.length)];
                       tv.setText(q1);
                     }
  
  
              }
          });
  
  
          //drop list
          Spinner spinner = (Spinner) findViewById(R.id.spinnerrrr);
          spinner.setOnItemSelectedListener(this);
  
  
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
                  R.array.kategorije, android.R.layout.simple_spinner_item);
  
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
  
          spinner.setAdapter(adapter);
  
      }
      // when some cat selected
      public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                                 final int pos, long id) {
          // An item was selected. You can retrieve the selected item using
          parent.getItemAtPosition(pos);
          parent.setSelection(0);
          parent.getSelectedItemPosition();
  
  
      }
  
  
  
  
  
      public void onNothingSelected(AdapterView&lt;?&gt; parent) {
          // Another interface callback
      }
  </code></pre>