File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
app/src/main/java/com/ahmadabuhasan/search Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 11package com .ahmadabuhasan .search ;
22
3+ import android .content .Context ;
34import android .os .Bundle ;
45import android .text .Editable ;
56import android .text .TextWatcher ;
67import android .view .View ;
8+ import android .view .inputmethod .InputMethodManager ;
79import android .widget .EditText ;
810import android .widget .Toast ;
911
@@ -29,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
2931 super .onCreate (savedInstanceState );
3032 setContentView (R .layout .activity_main );
3133
34+ hideKeyboard ();
3235 etSearch = findViewById (R .id .etSearch );
3336
3437 recyclerView = findViewById (R .id .data_recyclerView );
@@ -69,4 +72,12 @@ public void afterTextChanged(Editable s) {
6972 }
7073 });
7174 }
75+
76+ public void hideKeyboard () {
77+ View view = this .getCurrentFocus ();
78+ if (view != null ) {
79+ InputMethodManager imm = (InputMethodManager ) getSystemService (Context .INPUT_METHOD_SERVICE );
80+ imm .hideSoftInputFromWindow (view .getWindowToken (), 0 );
81+ }
82+ }
7283}
You can’t perform that action at this time.
0 commit comments