按下按钮:将键盘隐藏在react-native中

时间:2018-07-31 08:49:19

标签: reactjs react-native react-native-android

我有这个simple screen

当我按下按钮时,键盘仍然会出现:“如何按下按钮:隐藏键盘”?

  

这是我的按钮代码

        manage = () => {
           const { navigate } = this.props.navigation;
        if (this.state.text.length === 10) {

          navigate('service',{text: this.state.text});
        } else {
        Alert.alert('الرجاء ادخال الرقم  الوطني المكون من 10 أرقام')
        }
        }
        <Button   title='التالي'
           backgroundColor="#C1272D"
   onPress={this.manage}>
  </Button>

1 个答案:

答案 0 :(得分:5)

尝试

import { Keyboard } from 'react-native'; 

Keyboard.dismiss()//Call where ever you needed

文档https://developer.android.com/about/versions/oreo/background#broadcasts