setOnItemClickListener不适用于Spinner.这是我的代码…
supplier.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent,View view,int position,long id) { // TODO Auto-generated method stub String msupplier=supplier.getSelectedItem().toString(); Log.e("Selected item : ",msupplier); } });
解决方法
setOnItemClickListener将不适用于微调.尝试使用这种方法:
setOnItemSelectedListener
更改你的代码如下:
supplier.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0,View arg1,int arg2,long arg3) { // TODO Auto-generated method stub String msupplier=supplier.getSelectedItem().toString(); Log.e("Selected item : ",msupplier); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } });