解决方法
嗯…如果在微调器中只有一个项目,请尝试使用setClickable(fasle)或setEnabled(false).
试试这个
public class SpinnerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Spinner spinner = (Spinner) findViewById(R.id.spinner1); List<String> list = new ArrayList<String>(); list.add("list 1"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); if (list.size() < 2) { spinner.setClickable(false); spinner.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v,MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Toast.makeText(SpinnerActivity.this,"Catch it!",Toast.LENGTH_SHORT).show(); } return true; } }); } } }