I tried to find answer in other posts, but I couldn't really find what i was looking for.
I'm building chat app and i want for keyboard to disappear when clicked on the RecyclerView with chat messages.
Simple way with code below doesn't work.
recyclerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("RecyclerTest", "Clicked");
hideKeyboard();
}
});
I know how to implement onClickListener
on Items inside the RecyclerView, but i was wondering if there is a way to add onClick on the whole RecyclerView, or should i just not bother and add onClick on every item in the adapter, and hide keyboard when either one is clicked?
EDIT:
My Hide Keyboard method
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) ChatRoom.this.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(ChatRoom.this.getCurrentFocus().getWindowToken(), 0);
}