package gr.mybook.mylistviews;

import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.view.View;
import android.widget.Spinner;

public class MySpinnerActivity extends Activity{
	String[] items;
	   @Override
	   public void onCreate(Bundle savedInstanceState) {
	      super.onCreate(savedInstanceState);
	      setContentView(R.layout.spinner);
	      items = getResources().getStringArray(R.array.items1);
	      Spinner spn = (Spinner) findViewById(R.id.spinner1);
	      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
	                android.R.layout.simple_spinner_item, items);
	      spn.setAdapter(adapter);
	      spn.setOnItemSelectedListener(new OnItemSelectedListener() {
	         @Override
	         public void onItemSelected(AdapterView<?> arg0, View arg1,
	                     int arg2, long arg3) {
	            int index = arg0.getSelectedItemPosition();
	            //TODO something with selected item
	         }
	         @Override
	         public void onNothingSelected(AdapterView<?> arg0) {}
	      });
	   }
}
