0

in my app i am having an edit text box. When the user clicks the edit box i want to show him a alert box at that time i dont want the keyboard to be popped up. For this my code is as follows

bd =(EditText)findViewById(R.id.dob);
bd.setHint("Birth Date");
bd.setOnClickListener(bdListener); 



private OnClickListener bdListener = new View.OnClickListener()
 {
     public void onClick(View v) 
     {
      hidesoftkeyboard();
      DOBalert();
     }
 }




private void hidesoftkeyboard()
  {
    InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromInputMethod(bd.getWindowToken(), 0);
  }

But still the keyboard is not hiding, where i am going wrong please help me friends

Siva K
  • 4,802
  • 14
  • 76
  • 156

4 Answers4

0

try this in ur activity

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
       boolean ret = super.dispatchTouchEvent(event);
       hidesoftkeyboard();          
       return ret;
    }
0

try adding this to your hidesoftkeyboard() method:

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

Or

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Vinayak Bevinakatti
  • 38,839
  • 25
  • 103
  • 135
0
 android:windowSoftInputMode=[         "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible",
                                       "adjustResize", ] >   

Use some of this in your manifest, this will hide the automatic keyboard pop up. However, if you are using your EditText for some input at time you'll need the keyboard. :)

Nikola Despotoski
  • 46,951
  • 13
  • 114
  • 146
-1

the above said answers is not working for me and at last i changed the edit boxes to be a text view.

Siva K
  • 4,802
  • 14
  • 76
  • 156