SetOnItemSelectedListener上的微调器错误

时间:2012-01-17 02:28:20

标签: android spinner

我有一个微调器,我这样做

 public class Settings extends Activity {

String[] items = new String[] {"English", "Deutsch", "日語"};
 SharedPreferences prefs;
  SharedPreferences.Editor prefEditor;
 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.settings);
        Spinner spinner = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_item, items);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
 spinner.setOnItemSelectedListener (new OnItemSelectedListener()  {


    });

语法错误表明OnItemSelectedListener无法解析为类型。方法setOnItemSelectedListener不适用

2 个答案:

答案 0 :(得分:15)

这是日食的常见问题。只需手动添加:

import android.widget.AdapterView.OnItemSelectedListener;

答案 1 :(得分:1)

修复您的导入。如果在Eclipse上按ctrl + shift + o。