设置界面后如何触发 Spinner 的 onItemSelected ?
我有一个带有 Spinner 的 Android 视图。 我调用 populateSpinner() 方法向其添加一些默认值。
我还有一个 onItemSelected()
事件,该事件在视图完成打印之前被调用。 我想仅在用户更改所选项目时运行此块内的代码,而不是在我添加或创建表单时运行代码。
这怎么可能?
I am having an Android view with a Spinner on it.
I call a populateSpinner() method to add some default values to it.
I also have a onItemSelected()
event which gets called before the view is completed to print.
I would like to run a code inside this block only when the user changes the selected items, not when I add or the form gets created.
How is possible that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过等到填充 Spinner 后再注册 onItemSelectedListener?
Have you tried waiting until you have populated the Spinner to register the onItemSelectedListener?
Pentium10,我找到了这个问题的解决方案并将其发布在这里(带有代码示例):
Spinner onItemSelected() 在不应该执行时执行
Pentium10, I have found a solution for this problem and posted it here (with code sample):
Spinner onItemSelected() executes when it is not suppose to