How to hide default keyboard from ListViewAdapter in android

I use the ListViewAdapter to bind the ListView on my home page and to the user keyboard. But when I clicked on EditText, the default keyboard will appear.

I tried to hide it using the following code:

InputMethodManager mgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(diesel.getWindowToken(), 0); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

But that did not work.

How to hide default keyboard from ListViewAdapter?

+4
source share
3 answers
Finally, I get it. I solved this problem. just added below to the ListViewAdapter.

(EditTextName) .setInputType (0);

Now it will not open the default keyboard in EditText. Click or tap.

+4
source

The adapter is not suitable for any user interface activity.

+3
source

If you want to hide the keyboard for events such as clicking a button, use this

 public void onClick(View v) { InputMethodManager imm = (InputMethodManager) v.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } 
0
source

Source: https://habr.com/ru/post/1448098/


All Articles