我有一个带有数组的微调器,我在一个名为 array.spinner_title 的 string.xml 中创建
我怎样才能在项目上选择她,以便我可以选择项目
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) {
}
});
谢谢