Android setOnEditorActionListener() doesn't fire

setoneditoractionlistener edittext android
cannot resolve symbol setoneditoractionlistener
android:imeoptions
setoneditoractionlistener in xamarin android
android:imeoptions=actionsearch
android edittext events
android:text input
keyboard done button click android

I'm trying to set a listener to EditText when enter button will be pressed.But it didn't fire at all. I tested this on LG Nexus 4 with Android 4.2.2. setOnEditorActionListener works on Amazon Kindle Fire with Android 2.3 and setImeActionLabel works nowhere! I also can't set text for Enter button.Here is code:

mEditText.setImeActionLabel("Reply", EditorInfo.IME_ACTION_UNSPECIFIED);
mEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId,
                KeyEvent event) {
            Log.d("TEST RESPONSE", "Action ID = " + actionId + "KeyEvent = " + event);
            return true;
        }  
    });

What am I doing wrong? How can I fix this?

You can use TextWatcher.

    editText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.charAt(s.length() - 1) == '\n') {
                  Log.d("TEST RESPONSE", "Enter was pressed");
            }
        }
    });

TextView.OnEditorActionListener, Android Developers. Docs More. Platform Android Studio Google Play Jetpack Kotlin News. Language, Bahasa Indonesia, Deutsch, English  OnEditorActionListener not working. Well it is working on Android 2.3.3 and not working on 4.1.2 Any It works on my Samsung but for some reason doesn't work

Make sure that you have an IME_ACTION set in the layout file:

<EditText
    android:id="@+id/search"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/search_hint"
    android:inputType="text"
    android:imeOptions="actionSend" />

For a full explanation, see http://developer.android.com/guide/topics/ui/controls/text.html.

Java Code Examples android.widget.EditText , Java Code Examples for android.widget.EditText.setOnEditorActionListener(). The following are Jave code examples for showing how to use  ajax android angular api button c++ class database date dynamic exception file function html http image input java javascript jquery json laravel list mysql object oop ph php phplaravel phpmysql phpphp post python sed select spring sql string text time url view windows wordpress xml

What worked for me is this,I have added this below line to EditText

android:imeOptions="actionSend"

this line makes keyboard which pops up when clicked on edit text has send button instead of search

in the setOnEditorActionListener you override following method looking for action send

@Override
    public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
        if (actionId == EditorInfo.IME_ACTION_SEND) {
        //implement stuff here
          }
        }

Java Code Examples android.widget.AutoCompleteTextView , AutoCompleteTextView.setOnEditorActionListener(). The following are Jave code examples for showing how to use setOnEditorActionListener() of the android. I see this code on developer.android.com for handle the IME_ACTION of the softkeyboard: EditText editText = (EditText) findViewById(R.id.search); editText.setOnEditorActionListener(new

In the xml file add tag android:inputType="text" to the EditText

android.widget.TextView.setOnEditorActionListener java code , using android.widget.TextView.setOnEditorActionListener (Showing top 20 results out of 315). Common ways to obtain TextView. private void myMethod () {. The following are top voted examples for showing how to use android.widget.TextView.OnEditorActionListener.These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.

I use the following code

<EditText
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toRightOf="@id/ic_magnify"
    android:layout_centerVertical="true"
    android:textSize="15sp"
    android:textColor="#000"
    android:id="@+id/input_search"
    android:inputType="text"
    android:background="@null"
    android:hint="Enter Address, City or Zip Code"
    android:imeOptions="actionSearch"/>

mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent) {

                if(actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE
                        || keyEvent.getAction() == KeyEvent.ACTION_DOWN || keyEvent.getAction() == KeyEvent.KEYCODE_ENTER){

                        geoLocate();

                }

                return false;
            }
        });

android.widget.EditText.setOnEditorActionListener java code , setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {. public virtual void SetOnEditorActionListener (TextView.IOnEditorActionListener l) I can't find any documentation on how to use this, or whether there is actually any support for this in the current Mono for Android. Is there support for doing this? If so is there anyone feeling generous enough to enlighten me or point me towards an example.

Binding for EditText.setOnEditorActionListener() · Issue #1 , You will want to look at the android:imeActionId and android:imeOptions attributes, plus the setOnEditorActionListener() method, all on TextView . For changing the The scrollHorizontal attribute doesn't make any difference. The null test is  Android Quick Tip. Close the keyboard when you click ‘DONE’… seems like a simple task, right? Unfortunately, clicking ‘DONE’ or the ‘RETURN’ button in even a single line Android EditText will not drop focus and close the soft keyboard. In most cases it will just generate a new line of text.

Android Quick Tip: EditText with DONE Button That Closes the , Android Quick Tip Close the keyboard when you click 'DONE'… seems like to the target EditText via the setOnEditorActionListener() method. Questions: I am wondering if there is a way to handle the user pressing Enter while typing in an EditText, something like the onSubmit HTML event. Also wondering if there is a way to manipulate the virtual keyboard in such a way that the “Done” button is labeled something else (for example “Go”) and performs

Is there a more elegant solution for multiple IME_ACTION_DONE , setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if  Android Platform. API level 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1. Manifest.permission. Manifest.permission_group. android.accessibilityservice. AccessibilityService.MagnificationController.OnMagnificationChangedListener. AccessibilityService.SoftKeyboardController.OnShowModeChangedListener.

Comments
  • Thanks.It works. But don't you know why .setImeActionLabel and setOnEditorActionListener doesn't work on Nexus 4 but work in other devices?
  • Android fragmentation magic. For my Galaxy Nexus they also don't work
  • For me the imeOptions only worked if the you set singleLine="true" on the EditText. Seems weird and annoying that might be by design but that is what I found.
  • For me it doesn't work, even after adding singleLine="true" in ET attributes. The devices i noticed are Nexus 6, Nexus 4 and Moto G. the similarity in all is Android 5.0 ! So, if anyone comes across the same issue. provide an answer please.
  • For Kotlin, the condition will be like so: if(s[s.length - 1] == '\n')
  • And this line: android:inputType="text"
  • Add android:imeOptions="actionSend" too
  • I've this in my logcat : Action ID = 66KeyEvent = KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ENTER, scanCode=0, metaState=0, flags=0x6, repeatCount=0, eventTime=653776952, downTime=653776952, deviceId=-1, source=0x0 } and i'm using my code
  • Read the docs for View.OnKeyListener, "This is only useful for hardware keyboards; a software input method has no obligation to trigger this listener." developer.android.com/reference/android/view/…