ArrayAdapter<CharSequence> adapter_height = ArrayAdapter.createFromResource(this,R.array.Height,android.R.layout.simple_spinner_item);
adapter_height.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
height_spinner.setAdapter(adapter_height);
height_spinner.getOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
微调器无法使用“ getOnItemSelectedListener”方法。请提出修改建议并解决我的问题 [错误如上所示] https://i.stack.imgur.com/jym1L.png
答案 0 :(得分:0)
您必须使用setOnItemSelectedListener
而不是getOnItemSelectedListener
。如下所示。
height_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});