本文整理了Java中android.text.TextWatcher
类的一些代码示例,展示了TextWatcher
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextWatcher
类的具体详情如下:
包路径:android.text.TextWatcher
类名称:TextWatcher
暂无
代码示例来源:origin: facebook/litho
@Override
public void afterTextChanged(Editable editable) {
for (TextWatcher w : mTextWatchers) {
w.afterTextChanged(editable);
}
}
}
代码示例来源:origin: facebook/litho
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
for (TextWatcher w : mTextWatchers) {
w.onTextChanged(s, start, before, count);
}
}
代码示例来源:origin: facebook/litho
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
for (TextWatcher w : mTextWatchers) {
w.beforeTextChanged(s, start, count, after);
}
}
代码示例来源:origin: stackoverflow.com
mTextWatcher.beforeTextChanged(s, start, count, after);
mTextWatcher.onTextChanged(s, start, before, count);
public void afterTextChanged(Editable s) {
if(mTextWatcher != null)
mTextWatcher.afterTextChanged(s);
代码示例来源:origin: stackoverflow.com
resultsText = (android.widget.TextView)findViewById(R.id.textView16);
android.text.TextWatcher inputTextWatcher = new android.text.TextWatcher() {
public void afterTextChanged(android.text.Editable s) {
calculateResult();
代码示例来源:origin: facebook/litho
@Override
public void afterTextChanged(Editable s) {
if (mDelegates != null) {
for (int i = 0, stop = mDelegates.size(); i < stop; i++) {
mDelegates.get(i).afterTextChanged(s);
}
}
if (mTextChangedEventHandler != null) {
com.facebook.litho.widget.EditText.dispatchTextChangedEvent(
mTextChangedEventHandler, EditTextWithEventHandlers.this, s.toString());
}
}
}
代码示例来源:origin: facebook/litho
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (mDelegates != null) {
for (int i = 0, stop = mDelegates.size(); i < stop; i++) {
mDelegates.get(i).onTextChanged(s, start, before, count);
}
}
if ((mStateUpdatePolicy == UPDATE_ON_LINE_COUNT_CHANGE && mPrevLineCount != getLineCount())
|| mStateUpdatePolicy == UPDATE_ON_TEXT_CHANGE) {
com.facebook.litho.widget.EditText.updateInputSync(mComponentContext, s.toString());
} else if (mStateUpdatePolicy != NO_UPDATES) {
com.facebook.litho.widget.EditText.lazyUpdateInput(mComponentContext, s.toString());
}
}
代码示例来源:origin: facebook/litho
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (mDelegates != null) {
for (int i = 0, stop = mDelegates.size(); i < stop; i++) {
mDelegates.get(i).beforeTextChanged(s, start, count, after);
}
}
// Only need the previous line count when state update policy is ON_LINE_COUNT_CHANGE
if (mStateUpdatePolicy == UPDATE_ON_LINE_COUNT_CHANGE) {
mPrevLineCount = getLineCount();
}
}
代码示例来源:origin: morogoku/MTweaks-KernelAdiutorMOD
@Override
public void afterTextChanged(Editable s) {
if (mTextWatcher != null) {
mTextWatcher.afterTextChanged(s);
}
mText = s;
}
});
代码示例来源:origin: robolectric/robolectric
@Test
public void whenSettingText_ShouldFireOnTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.setText(NEW_TEXT);
ArgumentCaptor<SpannableStringBuilder> builderCaptor = ArgumentCaptor.forClass(SpannableStringBuilder.class);
verify(mockTextWatcher).onTextChanged(builderCaptor.capture(), eq(0), eq(INITIAL_TEXT.length()), eq(NEW_TEXT.length()));
assertThat(builderCaptor.getValue().toString()).isEqualTo(NEW_TEXT);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenSettingText_ShouldFireBeforeTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.setText(NEW_TEXT);
verify(mockTextWatcher).beforeTextChanged(INITIAL_TEXT, 0, INITIAL_TEXT.length(), NEW_TEXT.length());
}
代码示例来源:origin: sharish/WhatsappFormatter
private static void sendAfterTextChanged(TextWatcher[] mListeners, Editable s) {
if (mListeners != null) {
for (int i = 0; i < mListeners.length; i++) {
mListeners[i].afterTextChanged(s);
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldFireOnTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.append(NEW_TEXT);
ArgumentCaptor<SpannableStringBuilder> builderCaptor = ArgumentCaptor.forClass(SpannableStringBuilder.class);
verify(mockTextWatcher).onTextChanged(builderCaptor.capture(), eq(0), eq(INITIAL_TEXT.length()), eq(INITIAL_TEXT.length()));
assertThat(builderCaptor.getValue().toString()).isEqualTo(INITIAL_TEXT + NEW_TEXT);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldFireBeforeTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.append(NEW_TEXT);
verify(mockTextWatcher).beforeTextChanged(eq(INITIAL_TEXT), eq(0), eq(INITIAL_TEXT.length()), eq(INITIAL_TEXT.length()));
}
代码示例来源:origin: sunhapper/SpEditTool
@Override
public void afterTextChanged(Editable s) {
((TextWatcher) mObject).afterTextChanged(s);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenSettingTextToNull_WatchersSeeEmptyString() {
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.setText(null);
ArgumentCaptor<SpannableStringBuilder> builderCaptor = ArgumentCaptor.forClass(SpannableStringBuilder.class);
verify(mockTextWatcher).onTextChanged(builderCaptor.capture(), eq(0), eq(0), eq(0));
assertThat(builderCaptor.getValue().toString()).isEmpty();
}
代码示例来源:origin: sharish/WhatsappFormatter
private static void sendBeforeTextChanged(TextWatcher[] mListeners, CharSequence s, int start, int count, int after) {
if (mListeners != null) {
for (int i = 0; i < mListeners.length; i++) {
mListeners[i].beforeTextChanged(s, start, count, after);
}
}
}
代码示例来源:origin: hylinux1024/Componentization
@Override
public void afterTextChanged(Editable s) {
if (mTextWatcher != null) {
mTextWatcher.afterTextChanged(s);
}
}
}
代码示例来源:origin: sharish/WhatsappFormatter
private static void sendOnTextChanged(TextWatcher[] mListeners, CharSequence s, int start, int before, int count) {
if (mListeners != null) {
for (int i = 0; i < mListeners.length; i++) {
mListeners[i].onTextChanged(s, start, before, count);
}
}
}
代码示例来源:origin: hylinux1024/Componentization
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (mTextWatcher != null) {
mTextWatcher.beforeTextChanged(s, start, count, after);
}
}
内容来源于网络,如有侵权,请联系作者删除!