pub trait TextWatcher:
JObjRef
+ JObjNew
+ PartialEq
+ Debug {
const CLASS: &'static str = "android/text/TextWatcher";
const OBJECT_SIG: &'static str = "Landroid/text/TextWatcher;";
const DIM: u8 = 0u8;
// Required methods
fn before_text_changed(
&self,
s: Self::Cs,
start: i32,
count: i32,
after: i32,
);
fn on_text_changed(&self, s: Self::Cs, start: i32, before: i32, count: i32);
fn after_text_changed(&self, s: Self::E);
}
Expand description
当此类型的对象附加到 Editable 时,其方法将在文本改变时被调用。
Provided Associated Constants§
Sourceconst OBJECT_SIG: &'static str = "Landroid/text/TextWatcher;"
const OBJECT_SIG: &'static str = "Landroid/text/TextWatcher;"
Landroid/text/TextWatcher;
Required Methods§
Sourcefn before_text_changed(&self, s: Self::Cs, start: i32, count: i32, after: i32)
fn before_text_changed(&self, s: Self::Cs, start: i32, count: i32, after: i32)
调用此方法是为了通知您,在 s 中,从 start 开始的 count 个字符即将被长度为 after 的新文本替换。 尝试从此回调更改 s 是错误的。
Sourcefn on_text_changed(&self, s: Self::Cs, start: i32, before: i32, count: i32)
fn on_text_changed(&self, s: Self::Cs, start: i32, before: i32, count: i32)
调用此方法是为了通知您,在 s 中,从 start 开始的 count 个字符刚刚替换了之前长度为 before 的旧文本。 尝试通过此回调更改 s 是错误的。
Sourcefn after_text_changed(&self, s: Self::E)
fn after_text_changed(&self, s: Self::E)
调用此方法是为了通知您,在 s 中的某个地方,文本已发生更改。从此回调对 s 进行进一步更改是合法的,但请注意不要陷入无限循环,因为您所做的任何更改都会导致此方法再次递归调用。 (您不会被告知更改发生的位置,因为其他 afterTextChanged() 方法可能已经进行了其他更改并使偏移量无效。但如果您需要在此处知道,您可以在 onTextChanged 中使用 Spannable.setSpan 来标记您的位置,然后从此处查找 span 结束的位置。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.