7 Mar 2012

Physical Enter key of device in Android


EditText edtsearch=(EditText) findViewById(R.id.search_edttext);
       edtsearch.setOnEditorActionListener(new OnEditorActionListener()
       {

              public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
              {
if(actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_NULL|| event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
                     {                      
                           SearchValue=edtsearch.getText().toString();
InputMethodManager mgr = (InputMethodManager)   getSystemService(Context.INPUT_METHOD_SERVICE);
                           mgr.hideSoftInputFromWindow(edtsearch.getWindowToken(), 0);

                           //Wright your Code here................
                           return true;
                     }
                     else
                     {
                           return false;
                     }
              }
       }


I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

No comments:

Post a Comment