采用Android:数字属性限制字符停止行动下一步按钮工作 [英] Using Android:Digits attribute to restrict characters stops action next button working

查看:185
本文介绍了采用Android:数字属性限制字符停止行动下一步按钮工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司拥有一批在一个Android应用程序的EditText字段,我用的android:数字制止无效的字符被输入

I have a number of EditText fields on an Android app and I've used android:digits to stop invalid characters being input.

例如: 机器人:位数=@字符串/ validchars (其中validchars是所有有效字符的字符串资源 - 如AZ,0-9,和一些标点符号)

eg: android:digits="@string/validchars" (where "validchars" is a string resource of all the valid characters - eg A-Z, 0-9, and some punctuation )

现在的问题是,如果用户点击软键盘它曾经带他们到下一个字段上的回车键,但自从我加入的Andr​​oid版本:数字位此已停止工作。我试着将\ n提供给validchars但这恰恰让马车在单行文本框返回(!),所以没有帮助。我试着用imeOptions(添加actionNext等),顺藤摸瓜,但这似乎并没有任何解决它。 我读过有关TextWatchers和InputFilters但两者似乎过于复杂,我想要做的和android:位位工作正常,在停止无效字符

The problem is, if the user hits the ENTER key on the soft keyboard it used to take them to the next field but since I added android:digits bit this has stopped working. I've tried adding \n to the validchars but this just allows Carriage Returns in the single line textboxes (!) so doesn't help. I've tried fiddling with the imeOptions (adding actionNext etc) but this doesn't seem to fix it either. I've read about TextWatchers and InputFilters but both seem to be over-complicated for what I'm trying to do and the android:digits bit works fine in stopping the invalid characters.

有没有人有什么想法?

Has anyone got any ideas?

我使用的Andr​​oid SDK版本8,并针对这两个2.2和2.3.5的设备。

I'm using Android SDK version 8 and targeting both 2.2 and 2.3.5 devices.

感谢

推荐答案

在一个位与一个EditText我发现可用的属性闲逛的,当我加入的android:单线=真ENTER键现在移动焦点下一个领域,即使在机器人:数字是制约输入的字符。问题解决了! (对我来说,反正!)

After a bit of poking around with the attributes available for an EditText I found that when I add android:singleLine="true" the ENTER key now moves the focus to the next field, even when a android:digits is restricting the characters entered. Problem solved! (for me, anyway!)

这篇关于采用Android:数字属性限制字符停止行动下一步按钮工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆