Create spinner from Array, and the set item changed listener
final String[] messageCategories = getActivity().getResources().getStringArray(R.array.message_category);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.message_category, R.layout.simple_spinner_item);
adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
mMessageCategorySpinner.setAdapter(adapter);
mMessageCategorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String selectedMessageCategory = adapterView.getItemAtPosition(i).toString();
Log.v(TAG, "Selected message category : " + selectedMessageCategory);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});