[英]reactNative TextInput number-pad not showing properly on android
Im using我正在使用
TextInput
文本输入
with与
keyboardType = "number-pad"
keyboardType = "数字键盘"
On iOS it works fine, but on Android it shows normal keyboard, how do I make android show the number-pad keyboard, and hide the "suggest" bar在 iOS 上它工作正常,但在 Android 上它显示普通键盘,我如何让 android 显示数字键盘,并隐藏“建议”栏
On the left the iOS showing correctly, on the right the android emulator showing wrong keyboard.
左边的 iOS 显示正确,右边的 android 模拟器显示错误的键盘。
<TextInput
ref="second"
style={this.state.pos > 0 ? styles.textInputStyle :
styles.textInputNormalStyle}
keyboardType = "number-pad"
maxLength={1}
value={this.state.secondVal}
onKeyPress={(event) => {this.onChange(1, event.nativeEvent.key); }}
/> />
As per the docs , you need to supply keyboardType as phone-pad
.根据docs ,您需要提供keyboardType作为
phone-pad
。
number-pad
is only for IOS number-pad
仅适用于IOS
For hiding the bar try autoCorrect={false}
要隐藏栏,请尝试
autoCorrect={false}
Edit编辑
As per the latest docs number-pad
has been added for cross-platform support根据最新的文档,
number-pad
已添加用于跨平台支持
for me that keyboardType='number-pad'
isn't working on Android yet even though the doc says it's available cross-platform!对我来说,即使文档说它可以跨平台使用,
keyboardType='number-pad'
还不能在 Android 上运行! (which is quite weird) so my solution was just validating the value before setting it as the input value (这很奇怪)所以我的解决方案只是在将其设置为输入值之前验证该值
const onChangeText = (text) => {
setInputValue(text.replace(/\D/g, ""));
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.