i have spinner with array that i create in a string.xml which called array.spinner_title
how can i do the on item select her so i can get the item selected
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( SendTeacher.this,
R.array.spinner_title, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
// Do something
}
@Override
public void onNothingSelected(AdapterView<?> adapter) {
}
});
thanks
As I understand your question , you want to get the selected item.
In:
For custom adapter which can contain any other objects (not only CharSequence), see this link for example