当前位置: 首页>>代码示例>>Java>>正文


Java Editable.delete方法代码示例

本文整理汇总了Java中android.text.Editable.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Editable.delete方法的具体用法?Java Editable.delete怎么用?Java Editable.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.Editable的用法示例。


在下文中一共展示了Editable.delete方法的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);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:10,代码来源:ExEditText.java

示例2: handleIgnoredTag

import android.text.Editable; //导入方法依赖的package包/类
/**
 * When we come upon an ignored tag, we mark it with an Annotation object with a specific key
 * and value as above. We don't really need to be checking these values since Html.fromHtml()
 * doesn't use Annotation spans, but we should do it now to be safe in case they do start using
 * it in the future.
 * @param opening If this is an opening tag or not.
 * @param output Spannable string that we're working with.
 */
private void handleIgnoredTag(boolean opening, Editable output) {
    int len = output.length();
    if (opening) {
        output.setSpan(new Annotation(IGNORED_ANNOTATION_KEY, IGNORED_ANNOTATION_VALUE), len,
                       len, Spannable.SPAN_MARK_MARK);
    } else {
        Object start = getOpeningAnnotation(output);
        if (start != null) {
            int where = output.getSpanStart(start);
            // Remove the temporary Annotation span.
            output.removeSpan(start);
            // Delete everything between the start of the Annotation and the end of the string
            // (what we've generated so far).
            output.delete(where, len);
        }
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:HtmlConverter.java

示例3: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
	if (editText == null)
		return;
	int editStart = editText.getSelectionStart();
	int editEnd = editText.getSelectionEnd();
	editText.removeTextChangedListener(this);
	while (StringUtil.counterChars(s.toString()) > maxLength) {
		s.delete(editStart - 1, editEnd);
		editStart--;
		editEnd--;
	}
	editText.setSelection(editStart);
	editText.addTextChangedListener(this);
	if (show && lengthTV != null) {
		long remainLength = maxLength - StringUtil.counterChars(s.toString());
		lengthTV.setText("" + remainLength / 2);
		lengthTV.setVisibility(View.VISIBLE);
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:21,代码来源:EasyEditDialog.java

示例4: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
	// 去除尾部多余的0
	String text = s.toString();
	if (null != text && !TextUtils.isEmpty(text)) {
		int len = text.length();
		if (len == 2 && text.startsWith("0")) {
			s.delete(0, 1);
		}
		if (len == 3 && text.startsWith("00")) {
			s.delete(0, 2);
		}
		if (len == 4 && text.startsWith("000")) {
			s.delete(0, 3);
		}
		if (len == 5 && text.startsWith("0000")) {
			s.delete(0, 4);
		}
	}
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:21,代码来源:CustomEditText.java

示例5: removeAutocomplete

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Remove any autocomplete text
 *
 * @param text Current text content that may include autocomplete text
 */
private boolean removeAutocomplete(final Editable text) {
    final int start = text.getSpanStart(AUTOCOMPLETE_SPAN);
    if (start < 0) {
        // No autocomplete text
        return false;
    }

    beginSettingAutocomplete();

    // When we call delete() here, the autocomplete spans we set are removed as well.
    text.delete(start, text.length());

    // Keep mAutoCompletePrefixLength the same because the prefix has not changed.
    // Clear mAutoCompleteResult to make sure we get fresh autocomplete text next time.
    mAutoCompleteResult = AutocompleteResult.emptyResult();

    // Reshow the cursor.
    setCursorVisible(true);

    endSettingAutocomplete();
    return true;
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:28,代码来源:InlineAutocompleteEditText.java

示例6: onClick

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
  if (passwordField != null) {
    switch (v.getId()) {
      case R.id.login_keyboard_key_backspace: {
        Editable editable = passwordField.getText();
        int charCount = editable.length();
        if (charCount > 0) {
          editable.delete(charCount - 1, charCount);
        }
      }
      break;
      case R.id.login_keyboard_key_sos:
        Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/AtlantHelpBot"));
        getContext().startActivity(telegram);
        break;
      default: {
        passwordField.append(((TextView) v).getText());
      }
      break;
    }
  }
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:24,代码来源:LoginKeyboardView.java

示例7: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
    final RichEditText.TagSpan span = willDelSpan;
    log("TagSpanTextWatcher#willRemove#span:" + (span == null ? "null" : span.toString()));
    if (span != null && span.willRemove) {
        int start = s.getSpanStart(span);
        int end = s.getSpanEnd(span);

        // Remove the span
        s.removeSpan(span);

        // Remove the remaining emoticon text.
        if (start != end) {
            s.delete(start, end);
        }
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:18,代码来源:RichEditText.java

示例8: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
    int editEnd = editText.getSelectionEnd();
    editText.removeTextChangedListener(this);
    while (StringUtil.counterChars(s.toString()) > length && editEnd > 0) {
        s.delete(editEnd - 1, editEnd);
        editEnd--;
    }
    editText.setSelection(editEnd);
    editText.addTextChangedListener(this);
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:12,代码来源:StringTextWatcher.java

示例9: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
    if (inputType == INPUT_ZH) {
        int l = s.length();
        while (--l >= 0) {
            if (s.charAt(l) < 0x4E00 || s.charAt(l) > 0x9FB0) {
                s.delete(l, l + 1);
            }
        }
    }
    ((TextView) findViewById(R.id.ced_confirm)).setTextColor(TextUtils.isEmpty(s.toString().trim())
            ? context.getResources().getColor(R.color.forbid_click_color)
            : context.getResources().getColor(R.color.base_blue));
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:15,代码来源:CommonEditDialog.java

示例10: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
	if(inputType==INPUT_ZH){
		int l=s.length();
		while(--l>=0){
			if(s.charAt(l)<0x4E00||s.charAt(l)>0x9FB0){
				s.delete(l, l+1);
			}
		}
	}
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:12,代码来源:CommonDeleteDialog.java

示例11: removeTasksBetweenIndexes

import android.text.Editable; //导入方法依赖的package包/类
private static List<SttTaskWithParserInfo> removeTasksBetweenIndexes(Editable editable, int indexSomewhereInLineStart, int indexSomewhereInLineEnd) {
    int len = editable.length();
    final SttCommander.SttTasksInTextRange found = SttCommander.get()
            .findTasksBetweenIndex(editable.toString(), indexSomewhereInLineStart, indexSomewhereInLineEnd);

    // Finally delete
    if (found.startIndex >= 0 && found.startIndex < len && found.endIndex >= 0 && found.endIndex <= len) {
        editable.delete(found.startIndex, found.endIndex);
        return found.tasks;
    } else {
        return new ArrayList<>();
    }
}
 
开发者ID:gsantner,项目名称:markor,代码行数:14,代码来源:TodoTxtTextModuleActions.java

示例12: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable editable) {
    editStart = id_et_input.getSelectionStart();
    editEnd = id_et_input.getSelectionEnd();
    // 先去掉监听器,否则会出现栈溢出
    id_et_input.removeTextChangedListener(mTextWatcher);
    if (ignoreCnOrEn) {
        //当输入字符个数超过限制的大小时,进行截断操作
        while (calculateLengthIgnoreCnOrEn(editable.toString()) > MAX_COUNT) {
            editable.delete(editStart - 1, editEnd);
            editStart--;
            editEnd--;
        }
    } else {
        // 因为是中英文混合,单个字符而言,calculateLength函数都会返回1
        while (calculateLength(editable.toString()) > MAX_COUNT) { // 当输入字符个数超过限制的大小时,进行截断操作
            editable.delete(editStart - 1, editEnd);
            editStart--;
            editEnd--;
        }
    }
    id_et_input.setSelection(editStart);
    // 恢复监听器
    id_et_input.addTextChangedListener(mTextWatcher);
    //update
    configCount();
}
 
开发者ID:yangchong211,项目名称:YCMultiInputView,代码行数:28,代码来源:MultiEditInputView.java

示例13: removeSeparators

import android.text.Editable; //导入方法依赖的package包/类
public static void removeSeparators(Editable s) {
    int index = TextUtils.indexOf(s, SEPARATOR);
    while (index >= 0) {
        s.delete(index, index + 1);
        index = TextUtils.indexOf(s, SEPARATOR, index + 1);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:CreditCardNumberFormattingTextWatcher.java

示例14: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
public void afterTextChanged(Editable s) {
    int i = this.cou;
    getClass();
    if (i > 10) {
        this.selectionEnd = LeBoxMainActivity.this.mLeBoxName.getSelectionEnd();
        getClass();
        s.delete(10, this.selectionEnd);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:LeBoxMainActivity.java

示例15: extractSpanText

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Returns the text contained within a span and deletes it from the output string
 */
private CharSequence extractSpanText(Editable output, Class kind) {
    final Object obj = getLast(output, kind);
    // start of the tag
    final int where = output.getSpanStart(obj);
    // end of the tag
    final int len = output.length();

    final CharSequence extractedSpanText = output.subSequence(where, len);
    output.delete(where, len);
    return extractedSpanText;
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:15,代码来源:HtmlTagHandler.java


注:本文中的android.text.Editable.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。