Android EditText事件处理程序,以获得按键已按下的通知

Android EditText事件处理程序,以获得按键已按下的通知,android,android-edittext,Android,Android Edittext,应用程序需要知道在编辑过程中按下新键的时间文本是否已被使用、填充。这是哈得勒为它举办的任何活动吗?在iOS forUITextField中,使用了shouldChangeCharactersRange委托方法 <EditText android:layout_width="wrap_content" android:layout_height="30dp" android:id="@+id/editText" android:

应用程序需要知道在编辑过程中按下新键的时间文本是否已被使用、填充。这是哈得勒为它举办的任何活动吗?在iOS for
UITextField
中,使用了
shouldChangeCharactersRange
委托方法

<EditText
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:id="@+id/editText"
        android:layout_alignParentBottom="false"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="18dp"
        android:layout_marginLeft="8dp"
        android:width="100dp"
        android:on/> <----- some event handler need here but only onclick I see

在编辑文本字段的文本时,您可以使用
TextChangedListener
编辑文本,以接收事件

yourEditText.addTextChangedListener(new TextWatcher() {

    public void afterTextChanged(Editable s) {

    }

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

    }

    public void onTextChanged(CharSequence s, int start, int before, int count) {
        Log.i("TAG","text = "+yourEditText.getText().toString());
    }
});

您知道为什么我无法在布局文件中看到
TextChangedListener
?为问题添加了一个屏幕截图。@János将其添加到您的Java代码中(在您的活动的onCreate方法中),我看到了,但从布局xml来看,这是不可能的?@János我确实认为在布局xml中是不可能的。我在哪里可以阅读有关您使用的Java语言元素的更多信息?U将块/未命名方法作为侦听器传递,但此方法有3个子方法?在JAVA中,方法可以命名为“submethods”?我对斯威夫特了解得更多,我在哪里能读到关于这个结构的书?