android.text.TextWatcher.onTextChanged()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中android.text.TextWatcher.onTextChanged()方法的一些代码示例,展示了TextWatcher.onTextChanged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextWatcher.onTextChanged()方法的具体详情如下:
包路径:android.text.TextWatcher
类名称:TextWatcher
方法名:onTextChanged

TextWatcher.onTextChanged介绍

暂无

代码示例

代码示例来源: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 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: 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 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 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 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: morogoku/MTweaks-KernelAdiutorMOD

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  if (mTextWatcher != null) {
    mTextWatcher.onTextChanged(s, start, before, count);
  }
}

代码示例来源:origin: sunhapper/SpEditTool

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

代码示例来源:origin: yydcdut/RxMarkdown

private void sendOnTextChanged(CharSequence s, int start, int before, int after) {
  if (mListeners != null) {
    final ArrayList<TextWatcher> list = mListeners;
    final int count = list.size();
    for (int i = 0; i < count; i++) {
      list.get(i).onTextChanged(s, start, before, after);
    }
  }
}

代码示例来源:origin: googlesamples/android-AutofillFramework

protected void setText(CharSequence value) {
  if (!editable) {
    Log.w(TAG, "Item for id " + id + " is not editable: " + this);
    return;
  }
  text = value;
  if (mListener != null) {
    Log.d(TAG, "Notify listener: " + text);
    mListener.onTextChanged(text, 0, 0, 0);
  }
}

代码示例来源:origin: com.github.japgolly.android.test/robolectric

private void sendOnTextChanged(CharSequence oldValue) {
  for (TextWatcher watcher : watchers) {
    watcher.onTextChanged(text, 0, oldValue.length(), text.length());
  }
}

代码示例来源:origin: sharish/WhatsappFormatter

/**
 * Send an on text change event to child listeners
 *
 * @see {@link TextWatcher#onTextChanged(CharSequence, int, int, int)}
 */
private void sendOnTextChanged(CharSequence s, int start, int before, int count) {
  if (mListeners != null) {
    for (int i = 0; i < mListeners.size(); i++) {
      mListeners.get(i).onTextChanged(s, start, before, count);
    }
  }
}

代码示例来源:origin: dkzwm/FormatEditText

private void sendOnTextChanged(CharSequence s, int start, int before, int count) {
  if (mWatchers != null) {
    final List<TextWatcher> list = mWatchers;
    final int size = list.size();
    for (int i = 0; i < size; i++) {
      list.get(i).onTextChanged(s, start, before, count);
    }
  }
}

代码示例来源:origin: sharish/WhatsappFormatter

/**
 * Send an on text change event to child listeners
 * @see {@link TextWatcher#onTextChanged(CharSequence, int, int, int)}
 */
private void sendOnTextChanged(CharSequence s, int start, int before, int count) {
  if (mListeners != null) {
    for (int i = 0; i < mListeners.size(); i++) {
      mListeners.get(i).onTextChanged(s, start, before, count);
    }
  }
}

代码示例来源:origin: linkedin/Spyglass

/**
 * Notify external text watchers that the text is changing.
 * See {@link TextWatcher#onTextChanged(CharSequence, int, int, int)}.
 */
private void sendOnTextChanged(CharSequence text, int start, int before, int after) {
  final List<TextWatcher> list = mExternalTextWatchers;
  final int count = list.size();
  for (int i = 0; i < count; i++) {
    TextWatcher watcher = list.get(i);
    if (watcher != this) {
      watcher.onTextChanged(text, start, before, after);
    }
  }
}

代码示例来源:origin: hylinux1024/Componentization

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  QuickClearEditText.this.onTextChanged(s, start, before, count);
  if (mTextWatcher != null) {
    mTextWatcher.onTextChanged(s, start, before, count);
  }
  if (mAllowQuickClear && mQuickClearBtnWrapper != null) {
    if (s != null && s.length() > 0) {
      mQuickClearBtnWrapper.post(new Runnable() {
        @Override
        public void run() {
          mQuickClearBtnWrapper.setVisibility(View.VISIBLE);
        }
      });
    } else {
      mQuickClearBtnWrapper.setVisibility(View.INVISIBLE);
    }
  }
}

代码示例来源:origin: stackoverflow.com

mTextWatcher.onTextChanged(s, start, before, count);

相关文章