views:

466

answers:

2

dear friends,

i am using android:imeOptions="actionSearch"

in editText and my question is can i write my own event if user presses Searchbutton on Softkeyboard?

actualy i want to perform functionality of softkeyboard search button similar to button we use on android activity.

any help would be appriciated.

+1  A: 

Call setOnEditorActionListener() on the EditText to register a TextView.OnEditorActionListener that will be invoked when the user taps the action button on the soft keyboard.

CommonsWare
Look at the BluetoothChat sample that shipped with your SDK, also online at http://developer.android.com/resources/samples/BluetoothChat/index.html -- or look at this SO question: http://stackoverflow.com/questions/1538331/android-cant-figure-how-to-use-setimeactionlabel
CommonsWare
A: 
finally i used...

EditText   SearchEditText =(EditText)findViewById(R.id.txtMapSearch);
         SearchEditText.setOnEditorActionListener(new OnEditorActionListener(){ 



            @Override
            public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
                // TODO Auto-generated method stub
                 if(arg1 == EditorInfo.IME_ACTION_SEARCH) 
                 {

                  // search pressed and perform your functionality.                   
                 }
                 return false;
            }

         });
UMMA