Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide default keyboard from ListViewAdapter in android

I am using ListViewAdapter for binding ListView on my home page, and a custom keyboard. But when I clicked on EditText, the default keyboard displays.

I tried to hide it by 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 it didn't work.

How can I hide the default keyboard from ListViewAdapter?

like image 731
Ajay Avatar asked Nov 24 '12 13:11

Ajay


People also ask

What is windowSoftInputMode in Android?

Android windowSoftInputMode – Resize the application for the soft-keyboard. Posted on October 25, 2010 by Lars Vogel. Android has the so-called Input Method Framework to support different input methods, e.g. keyboard, soft-keyboard, handwriting etc.


3 Answers

Adapter is not the right place to do any UI related activities.

like image 45
Marcin Orlowski Avatar answered Sep 29 '22 06:09

Marcin Orlowski


If you want to hide the keyboard on events like click of button, use this

public void onClick(View v)
{
     InputMethodManager imm = (InputMethodManager) v.getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
like image 37
karan vs Avatar answered Sep 29 '22 08:09

karan vs


Finally i got it. i solved this problem. just added below line in ListViewAdapter.

(EditTextName).setInputType(0);

Now it will not open Default Keyboard on EditText Click or Touch.

like image 55
Ajay Avatar answered Sep 29 '22 08:09

Ajay