未选择默认单选按钮(J2ME、Java)
目前正在开发 J2ME 中的移动应用程序,并对 ChoiceGroup 单选按钮答案选项有疑问。 关于如何做到不选择默认答案有什么建议吗? 我们尝试过:
cg8.setSelectedIndex( -1, true );
但出现越界异常错误,
并且
cg8.setSelectedFlags( boolean[] )
全部为 false,但还得到另一个错误。
为了解决这个问题,我们还尝试创建一个不可见的单选按钮并将其设置为选中状态,但也找不到制作不可见的单选按钮的方法。
任何想法或建议将不胜感激!
Currently working on a mobile app in J2ME and have questions with ChoiceGroup radio button answer options. Any suggestion on how to make it so that no default answer is selected? We've tried:
cg8.setSelectedIndex( -1, true );
But get an out of bounds exception error
and
cg8.setSelectedFlags( boolean[] )
with all false, but also get another error.
To get around this, we've also tried creating an invisible radio button and have that set as selected, but couldn't find a way to make an invisible radio button either.
Any thoughts or suggestions would be great appreciated!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,该平台正在执行适当的约定,尽管我必须为在这里采取纯粹主义的立场而道歉; 这并不能真正回答你的问题。
当存在多个独占选择且必须选择其中一个时,使用单选按钮; 因此,对于用户界面来说,确保始终选择某些内容具有一定的意义。 理想情况下,无线电组中的初始选择应始终是安全且合理的默认值。
It sounds to me like the platform is enforcing an appropriate convention, although I must apologise for taking a purist standpoint here; this won't really answer your question.
Radio buttons are used when there are multiple exclusive choices, of which one must be made; it makes a certain amount of sense, therefore, for the user interface to ensure that something is always selected. Ideally, the initial selection in a radio group should always be a safe and sensible default.
据我所知,不预先选择任何单选按钮的唯一方法是自己绘制控件。 使用 Canvas 或 CustomItem 重新实现单选按钮列表。
不幸的是,这是一项繁重的工作。
您应该研究 LWUIT,因为它可能有一个中间解决方案。
As far as I know, the only way to not have any radio button pre-selected is to draw the control yourself. Re-implement a radio button list using a Canvas or a CustomItem.
It's a lot of work, unfortunately.
You should look into LWUIT as it may have an intermediary solution.