本文整理汇总了Java中android.text.Editable类的典型用法代码示例。如果您正苦于以下问题:Java Editable类的具体用法?Java Editable怎么用?Java Editable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Editable类属于android.text包,在下文中一共展示了Editable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteLast
import android.text.Editable; //导入依赖的package包/类
/**
* 删除最后一个字符,用来当@的人, 已经存在时,调用
*/
public void deleteLast(int position) {
Editable text = getText();
if (text != null && text.length() >= position) {
text.delete(position - 1, position);
}
}
示例2: onFinishInflate
import android.text.Editable; //导入依赖的package包/类
@Override protected void onFinishInflate() {
super.onFinishInflate();
ButterKnife.bind(this);
titleView.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
titleView.setError(Strings.isBlank(titleView.getText()) ? "Cannot be empty." : null);
}
});
titleView.addTextChangedListener(new EmptyTextWatcher() {
@Override public void afterTextChanged(Editable s) {
if (listener != null) {
listener.onStateChanged(!Strings.isBlank(s));
}
}
});
screenshotView.setChecked(true);
logsView.setChecked(true);
}
示例3: onClickSendButton
import android.text.Editable; //导入依赖的package包/类
@Override
public void onClickSendButton(Editable str) {
if (!TDevice.hasInternet()) {
AppContext.showToastShort(R.string.tip_network_error);
return;
}
if (!AccountHelper.isLogin()) {
UIHelper.showLoginActivity(getActivity());
return;
}
if (TextUtils.isEmpty(str)) {
AppContext.showToastShort(R.string.tip_comment_content_empty);
return;
}
handleComment(str.toString());
}
示例4: afterTextChanged
import android.text.Editable; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
int selection = mTextInput.getSelectionEnd();
if (s != null && s.toString().contains(".")) {
mTextInput.setText(s.toString().replace('.', ','));
mTextInput.setSelection(selection);
}
if (mSpecimen != null &&
mSpeciesId != Utils.MOOSE_ID &&
mSpeciesId != Utils.FALLOW_DEER_ID &&
mSpeciesId != Utils.WHITE_TAILED_DEER &&
mSpeciesId != Utils.WILD_FOREST_DEER) {
mSpecimen.setWeight(getWeight());
refreshWeightRequiredIndicator();
if (mCallback != null) {
mCallback.onSpecimenChanged();
}
}
}
示例5: afterTextChanged
import android.text.Editable; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (s != null && s.length() == 1) {
if (index < 7) {// 焦点后移
Log.d("gaolei", "index------------------" + index);
if (index < 6) {
EditText editText = getEditTextFromIndex(index);
editText.clearFocus();
getEditTextFromIndex(index + 1).requestFocusFromTouch();
}
currentEditIndex = index;
} else {
// TODO 判断
// handler.sendEmptyMessage(1);
}
} else {
// 清除 对应 标识位
}
}
示例6: testInvalidPassword
import android.text.Editable; //导入依赖的package包/类
@Test
public void testInvalidPassword() throws Resources.NotFoundException {
Editable mockEditable = mock(Editable.class);
int color = 50;
String text = "message";
when(mockEditable.toString()).thenReturn("invalidpassword");
when(mUserAdapter.checkValidPassword("invalidpassword"))
.thenReturn(false);
when(mResources.getColor(R.color.red)).thenReturn(color);
when(mContext.getString(R.string.invalid_password)).thenReturn(text);
mPasswordTextWatcher.afterTextChanged(mockEditable);
verify(mIcon).setImageResource(R.drawable.ic_cancel);
verify(mText).setText(text);
verify(mText).setTextColor(color);
}
示例7: afterTextChanged
import android.text.Editable; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (countryFormatter == null)
return;
if (TextUtils.isEmpty(s))
return;
countryFormatter.clear();
String number = s.toString().replaceAll("[^\\d.]", "");
String formattedNumber = null;
for (int i=0;i<number.length();i++) {
formattedNumber = countryFormatter.inputDigit(number.charAt(i));
}
if (formattedNumber != null && !s.toString().equals(formattedNumber)) {
s.replace(0, s.length(), formattedNumber);
}
}
示例8: onTextChange
import android.text.Editable; //导入依赖的package包/类
/**
* 文本变化处理
*/
private void onTextChange(Editable s)
{
text = s.toString();
fillText();
if(onInputChangeListener != null)
{
if(s.length() == maxLength)
{
onInputChangeListener.onFinished(this, text);
}
onInputChangeListener.onTextChanged(text.length() == maxLength, text);
}
}
示例9: startImg
import android.text.Editable; //导入依赖的package包/类
private void startImg(Editable text, Attributes attributes, HtmlCompat.ImageGetter img) {
String src = attributes.getValue("", "src");
Drawable d = null;
if (img != null) {
d = img.getDrawable(src, attributes);
}
if (d == null) {
Resources res = mContext.getResources();
d = res.getDrawable(R.drawable.unknown_image);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
}
int len = text.length();
text.append("\uFFFC");
text.setSpan(new ImageSpan(d, src), len, text.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
示例10: setupUserAutocomplete
import android.text.Editable; //导入依赖的package包/类
private void setupUserAutocomplete() {
EditText edit = (EditText) findViewById(R.id.single);
float elevation = 6f;
Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
AutocompletePresenter<User> presenter = new UserPresenter(this);
AutocompleteCallback<User> callback = new AutocompleteCallback<User>() {
@Override
public boolean onPopupItemClicked(Editable editable, User item) {
editable.clear();
editable.append(item.getFullname());
return true;
}
public void onPopupVisibilityChanged(boolean shown) {}
};
userAutocomplete = Autocomplete.<User>on(edit)
.with(elevation)
.with(backgroundDrawable)
.with(presenter)
.with(callback)
.build();
}
示例11: afterTextChanged
import android.text.Editable; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (Utils.doLog())
Log.d(CLASSNAME,
"afterTextChanged() >>> delayTimeSubmission = "
+ getDelayTimeSubmission());
if (TextUtils.isEmpty(mTextSearch.getText())) {
if (!isClosable())
mButtonClear.setVisibility(GONE);
} else
mButtonClear.setVisibility(VISIBLE);
if (getDelayTimeSubmission() > 0)
mAutoSubmissionHandler.postDelayed(mAutoSubmissionRunnable,
getDelayTimeSubmission());
}
示例12: onClick
import android.text.Editable; //导入依赖的package包/类
@Override
public void onClick(Fragment currentFragment, final RongExtension extension) {
String[] permissions = {Manifest.permission.RECORD_AUDIO};
if (!PermissionCheckUtil.requestPermissions(currentFragment, permissions)) {
return;
}
Recognizer recognizerView = new Recognizer(extension.getContext());
recognizerView.setResultCallBack(new IRecognizedResult() {
@Override
public void onResult(String data) {
Editable editable = extension.getInputEditText().getText();
String str = editable.toString() + data;
extension.getInputEditText().setText(str);
extension.getInputEditText().setSelection(str.length());
}
@Override
public void onClearClick() {
extension.getInputEditText().setText("");
}
});
extension.addPluginPager(recognizerView);
recognizerView.startRecognize();
}
示例13: enoughToFilter
import android.text.Editable; //导入依赖的package包/类
private boolean enoughToFilter() {
Editable s = getText();
int end = getSelectionEnd();
if (end < 0)
return false;
int start = findTokenStart();
boolean hasAt = s.length() > start && s.charAt(start) == '@';
updateCompletingCommandFlags();
return (mDoThresholdSuggestions && end - start >= THRESHOLD &&
(mDoAtSuggestions || !hasAt)) ||
(mDoAtSuggestions && hasAt) ||
(mDoChannelSuggestions && mChannelTypes != null && s.length() > start &&
mChannelTypes.contains(s.charAt(start))) ||
isCommandNameToken() || updateCompletingCommandFlags();
}
示例14: getCharArray
import android.text.Editable; //导入依赖的package包/类
final char[] getCharArray(boolean clear) {
Editable editable = super.getText();
char[] chars = new char[editable.length()];
editable.getChars(0, chars.length, chars, 0);
if (clear) editable.clear();
return chars;
}
示例15: afterTextChanged
import android.text.Editable; //导入依赖的package包/类
@Override
public void afterTextChanged(final Editable s) {
mQuery = s.toString();
if (mQuery.isEmpty()) {
mSearchAlgorithm.cancel(true);
mCb.clearSearchResult();
} else {
mSearchAlgorithm.cancel(false);
mSearchAlgorithm.doSearch(mQuery, mCb);
}
}