1

我想在用户单击特定选项卡时关闭键盘。

现在发生的情况是,当键盘打开并且用户想要切换到另一个选项卡时,他必须先关闭/最小化键盘。

a 上的道具可以满足ScrollView keyboardShouldPersistTaps我的要求,但仅适用于 a ScrollView,而不适用于TabNavigator组件。

4

1 回答 1

1

You can use a function to hide the keyboard and call it from onClick of that tab.

This is the function you should declare in the same class in which onClick of that tab exists.

@SuppressWarnings("ConstantConditions")
    public void hideKeyBoard(View view){
        InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),0);    
    }

And then from the onClick, just call this by using hideKeyBoard();.
This will hide the keyboard whenever that tab is tapped. And You should provide some of your code if seeking help.

于 2017-08-15T03:24:07.737 回答