这是我的代码:
String[] spinnerPresets = { "Test", "Test1", "Test2" };
final Spinner s1 = new Spinner(this);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, spinnerPresets);
s1.setAdapter(arrayAdapter);
s1.setPrompt("Presets");
s1.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
if(position==0) {
Toast.makeText(Activity.this, "TEST", Toast.LENGTH_LONG).show();
}
if(position==1) {
Toast.makeText(Activity.this, "TEST1", Toast.LENGTH_LONG).show();
}
if(position==2) {
Toast.makeText(Activity.this, "TEST2", Toast.LENGTH_LONG).show();
}
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
b2.setOnClickListener(new OnClickListener() {
public void onClick(View paramView) {
s1.performClick();
}
});
当我单击按钮时,它会显示我的微调器,但问题是当我在该微调器中选择其中一些项目时,它不会显示 Toast 消息。