您可以使用BackHandler
在本机反应中覆盖Android后退按钮功能。但是,当键盘打开并且按下后退按钮而不是进入hardwareBackPress
侦听器时,键盘将关闭。
答案 0 :(得分:0)
解决方案可能是这样
state = { keyboardopen: false };
BackHandler.removeEventListener("hardwareBackPress", this.handleBackPress);
Keyboard.addListener(
"keyboardDidShow",
() => this.setState({ keyboardopen: !keyboardopen })
);
handleBackPress = () => {
if (keyboardopen) {
// do some thing
} else {
//do some thing else
}
};