gpt4 book ai didi

android - 如何知道是否已在 android 中选择了微调项?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:09 25 4
gpt4 key购买 nike

我如何知道微调器中的项目是否已在 android 中被选中?

最佳答案

看这里: http://developer.android.com/resources/tutorials/views/hello-spinner.html

您必须实现一个 OnItemSelectedListener

这里是链接中的示例:

public class MyOnItemSelectedListener implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
Toast.makeText(parent.getContext()), "The planet is " +
parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}

public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}

spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

如果您不想为您的监听器显式声明一个类,您也可以使用匿名内部方法。

关于android - 如何知道是否已在 android 中选择了微调项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5257297/

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