Home > DeveloperSection > Forums > Problem in EditText input method action on setting imeActionLabel
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    November-06-2014 10:48 PM

 Android Android Edittext 
Ratings:


 1 Reply(s)
 678  View(s)
Rate this:
I have an Edittext with imeoptions asactiongo. and I triggered my event when pressing soft keyboard enter button.

mModelId.setOnEditorActionListener(new OnEditorActionListener() {

        @Override

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;

           // if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {

            if (actionId == EditorInfo.IME_ACTION_GO) {

 

                id = mModelId.getText().toString();

                System.out.println("Model id in Edittext:-"+ id);

                Toast.makeText(getActivity(), "You entered "+id, Toast.LENGTH_LONG).show();

                System.out.println("Before Call Volley");

                callVolley();

                handled = true;

            }

            return handled;

        }

    });

 

Everything works fine but when I add actionlabel to enter key the event is not firing.mModelId.setImeActionLabel("Search Model", KeyEvent.KEYCODE_ENTER);. What may be the problem?



Lillian Martin

Total Post:27

Points:189
Posted on    November-07-2014 1:26 AM

try this

declare edittext and OnEditorActionListener() like this

mModelId = (EditText) findViewById(R.id.edittext_id);

        mModelId.setImeActionLabel("Search Model", KeyEvent.KEYCODE_ENTER);

        mModelId.setOnEditorActionListener(new OnEditorActionListener() {

        @Override

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;

 

            if (actionId == KeyEvent.KEYCODE_ENTER) {

 

                id = mModelId.getText().toString();

                System.out.println("Model id in Edittext:-"+ id);

                Toast.makeText(getActivity(), "You entered "+id,    Toast.LENGTH_LONG).show();

                System.out.println("Before Call Volley");

                callVolley();

                handled = true;

            }

            return handled;

        }

    });


Don't want to miss updates? Please click the below button!

Follow MindStick