无法关闭数字输入

Dismiss of numeric Input not possible

我正在使用带有“十进制”键盘的输入组件。不幸的是,这个键盘没有可以自行关闭的按钮。 我的解决方法是在右侧显示一个图标,并对其执行适当的操作。但是,这样的可用性很差。

解决这个问题的最佳方法是什么?

<Input
            ref={purchasePriceInput}
            placeholder="Enter purchase price"
            returnKeyType={'next'}
            keyboardType = 'decimal-pad'
            onChangeText={value => setPurchasePrice(value)}
            label={'Purchase Price'}
            labelStyle={styles.label}
            rightIcon={<Icon
                        name='check'
                        type='font-awesome-5'
                        color='gray'
                        onPress={()=>{purchasePriceInput.current.blur()}}   //<-- my workaround
                      />}
           >
           {purchasePrice.toLocaleString()}
          </Input>

你只需要改变returnKeyType="done"

returnKeyType 确定 return 键的外观。

以下值适用于所有平台:

  • done
  • go
  • next
  • search
  • send

这些值只是外观

所以在你的情况下,next 有效,但它看起来像一个右箭头。