public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner=(Spinner)findViewById(R.id.spinner);
//스피너에 들어갈 데이터(item) 만들기
String []str=new String[]{"ti1","ti2","ti3","ti4"};
//adapter 생성
ArrayAdapter<String>aa=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, str);
spinner.setAdapter(aa);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Log.v("eun","position:"+position+" "+parent.getSelectedItem().toString());
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
}