Android 中仅获取用户的一个字符
我希望用户只输入一个字符。我想为每个字母都制作按钮,但这没用。你能推荐一些东西来解决这个问题吗?提前致谢..
I want user to enter just one character. I thought to make buttons for every letter, but this is useless. Could you recommend something to overcome this problem? Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 InputFilter.LengthFilter 来限制字符数可以输入到文本字段和自定义 InputFilter 来限制允许使用的字符;这对我来说听起来是最简单的方法。
这是一个例子:
You can use an InputFilter.LengthFilter to limit the number of characters that can be entered into a text field and a custom InputFilter to restrict the characters that are allowed; which sounds like the simplest approach to me.
Here's an example:
您可以在其他解决方案中创建一个字段并将事件处理程序设置为一次仅接受一个字符。
这与该问题非常接近:Validation on Edit Text
You could among other solutions make a field and set your event handler to only accept one character at the time.
This is very close to that question: Validation on Edit Text