Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Disable soft keyboard at all EditTexts

I am working on a dialog at Android with a few EditTexts. I've put this line at the onCreate() in order to disable the soft keyboard:

Keypad.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

The problem is that it works only when the dialog appear and doing nothing. When I move to the next EditText, the keyboard appears and not going down.

Does anybody have an idea how to solve this issue?

like image 203
Yaniv Avatar asked Apr 27 '11 11:04

Yaniv


People also ask

How do I turn off soft keyboard on Android?

Hiding the Soft Keyboard Programmatically You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.

How do I turn off soft keyboard on Android after clicking outside?

Ok everyone knows that to hide a keyboard you need to implement: InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);

How do I change the soft keyboard on my Android?

What to Know. Go to Settings > System > Languages & input. Tap Virtual keyboard and choose your keyboard. You can switch between keyboards by selecting the keyboard icon at the bottom of most keyboard apps.


3 Answers

If you take look on onCheckIsTextEditor() method implementation (in TextView), it looks like this:

@Override public boolean onCheckIsTextEditor() {     return mInputType != EditorInfo.TYPE_NULL; } 

This means you don't have to subclass, you can just:

((EditText) findViewById(R.id.editText1)).setInputType(InputType.TYPE_NULL);  

I tried setting android:inputType="none" in layout xml but it didn't work for me, so I did it programmatically.

like image 136
zeratul021 Avatar answered Sep 27 '22 17:09

zeratul021


create your own class that extends EditText and override the onCheckIsTextEditor():

public class NoImeEditText extends EditText {     public NoImeEditText(Context context, AttributeSet attrs) {         super(context, attrs);     }     @Override     public boolean onCheckIsTextEditor() {         return false;     } } 
like image 43
jkhouw1 Avatar answered Sep 27 '22 18:09

jkhouw1


Try this out..

edittext.setInputType(InputType.TYPE_NULL);      
if (android.os.Build.VERSION.SDK_INT >= 11)   
{  
    edittext.setRawInputType(InputType.TYPE_CLASS_TEXT);  
    edittext.setTextIsSelectable(true);  
}
like image 23
ASP Avatar answered Sep 27 '22 18:09

ASP