Reputation: 1270
I want to close the keyboard when the user clicks a particular tab.
What's happening now is that when the keyboard is open and the user wants to switch to another tab, he must close/minimize the keyboard first.
The prop on a ScrollView
keyboardShouldPersistTaps
does what I want, but only for a ScrollView
, not for a TabNavigator
component.
Upvotes: 1
Views: 312
Reputation: 6363
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.
Upvotes: 1