gpt4 book ai didi

android - SetOnItemSelectedListener 上的微调器错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:38:43 27 4
gpt4 key购买 nike

我有一个微调器,我就是这样做的

 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 方法不适用

最佳答案

这是 eclipse 上的常见问题。只需手动添加即可:

import android.widget.AdapterView.OnItemSelectedListener;

关于android - SetOnItemSelectedListener 上的微调器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8888959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com