gpt4 book ai didi

android - setOnItemClickListener 不适用于 Android Spinner

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:29:54 24 4
gpt4 key购买 nike

setOnItemClickListener 不适用于 android 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 不适用于 android 微调器。或者,尝试使用此方法:

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

}
});

关于android - setOnItemClickListener 不适用于 Android Spinner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15064498/

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