Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 1.44 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to hide keyboard automatically after sending e-mail using emailIntent
  2. Timer timer = new Timer();
  3.     timer.schedule(new TimerTask()
  4.     {
  5.         @Override
  6.         public void run()
  7.         {
  8.             InputMethodManager m = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  9.             if(m != null)
  10.             {
  11.                 m.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
  12.             }
  13.         }
  14.     }, 100);
  15. }**
  16.        
  17. public void hideKeyboard(final View aView){
  18.                  aView.post(new Runnable() {
  19.                     @Override
  20.                     public void run(){
  21.  
  22.                     InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
  23.                     inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
  24.                      }
  25.                  }
  26.     }
  27.     public void showKeyboard(final View aView) {
  28.         aView.post(new Runnable() {
  29.             @Override
  30.             public void run() {
  31.  
  32.                 InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  33.                 inputMethodManager.toggleSoftInputFromWindow(ListingScreen.this.getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
  34.             }
  35.         });
  36.     }
  37.        
  38. android:windowSoftInputMode="stateAlwaysHidden"
  39. android:configChanges="keyboardHidden"