本文整理汇总了Java中android.text.Editable.length方法的典型用法代码示例。如果您正苦于以下问题:Java Editable.length方法的具体用法?Java Editable.length怎么用?Java Editable.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Editable
的用法示例。
在下文中一共展示了Editable.length方法的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: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (mPossiblyNotMultiline) {
boolean found = false;
for (int i = s.length() - 1; i >= 0; --i) {
if (s.charAt(i) == '\n') {
found = true;
break;
}
}
if (!found) {
mMultiline = false;
int pos = mEditText.getSelectionStart();
mEditText.setInputType(mEditText.getInputType()
& (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
mEditText.setSelection(pos);
}
}
}
示例3: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
SpannableStringBuilder spannableString = (SpannableStringBuilder) s;
int startPos = -1, endPos;
char curChar;
String keyword;
setUpColorSpan(s);
resultKeyWordSet.clear();
for (int i = 0; i < s.length(); i++) {
curChar = s.charAt(i);
endPos = i ;
if (curChar == Constants.TAG_FLAG_CHAR) {
keyword = spannableString.subSequence(startPos == -1 ? i : startPos + 1, endPos).toString();
if (isFlagChanged(startPos, i)
&& nameList.contains(keyword)) {
s.setSpan(new ForegroundColorSpan(textColor), startPos, endPos + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
resultKeyWordSet.add(keyword);
}
startPos = i;
}
}
if(null!=callback){
callback.onUpdate(resultKeyWordSet);
}
}
示例4: onTextChange
import android.text.Editable; //导入方法依赖的package包/类
/**
* 默认的文本变化监听器文本变化时调用此方法,{@link #addDefaultTextChangeListener()}
*/
private void onTextChange(Editable s)
{
string = s.toString();
for(int i = 0; i < s.length(); i++)
{
fillTextByIndex(i);
}
for(int i = s.length(); i < textLength; i++)
{
list.get(i).setText("");
}
if(onInputFinishedListener != null)
{
if(s.length() == textLength)
{
onInputFinishedListener.onFinish(this, string);
}
onInputFinishedListener.onTextChanged(string.length() == textLength, string);
}
}
示例5: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (isActionInProgress()) return;
setActionInProgress(true);
boolean hasHiddenNewLine = s.length() > 0 && s.charAt(0) == NEWLINE;
if (mHasHiddenNewline && !hasHiddenNewLine && !isFirst()) {
// An hidden newline was removed! Pass stuff back.
// This might make us empty, and eventually, delete us.
LOG.w(logPrefix(), "afterTextChanged:",
"we had a hidden newline, but not anymore.",
"Passing \"isFirst line\" back.");
previous().acceptSpace(0);
}
setActionInProgress(false);
}
示例6: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable editable) {
//文本内容为空时, 解决光标不显示的BUG
if (editable.length() > 0) {
setMovementMethod(LinkMovementMethod.getInstance());
} else {
setMovementMethod(getDefaultMovementMethod());
}
}
示例7: start
import android.text.Editable; //导入方法依赖的package包/类
/**
* Mark the opening tag by using private classes
*/
private void start(Editable output, Object mark) {
int len = output.length();
output.setSpan(mark, len, len, Spannable.SPAN_MARK_MARK);
if (HtmlTextView.DEBUG) {
Log.d(HtmlTextView.TAG, "len: " + len);
}
}
示例8: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (s.length() > 0) {
mAddressDelete.setVisibility(View.VISIBLE);
} else {
mAddressDelete.setVisibility(View.INVISIBLE);
}
}
示例9: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (s.length() == 0) {
clear.setVisibility(View.GONE);
} else {
clear.setVisibility(View.VISIBLE);
}
}
示例10: endCode
import android.text.Editable; //导入方法依赖的package包/类
private void endCode(Editable output, XMLReader xmlReader) {
output.append(" ");
int code_end = output.length();
output.setSpan(new ForegroundColorSpan(Color.parseColor("#f44336")), code_start, code_end, Spannable.SPAN_MARK_MARK);
output.setSpan(new BackgroundColorSpan(Color.parseColor("#ffebee")), code_start, code_end, Spannable.SPAN_MARK_MARK);
//output.append(" ");
}
示例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<>();
}
}
示例12: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
if (s.length() > 0) {
mServerAuthPassReset.setVisibility(View.GONE);
mServerAuthPassCtr.setPasswordVisibilityToggleEnabled(true);
} else {
mServerAuthPassReset.setVisibility(View.VISIBLE);
mServerAuthPassCtr.setPasswordVisibilityToggleEnabled(false);
}
}
示例13: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable editable) {
if (editable.length() == 0) {
enterChatView1.setImageResource(R.drawable.ic_chat_send);
} else {
enterChatView1.setImageResource(R.drawable.ic_chat_send_active);
}
}
示例14: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
ImageButton btnSend = (ImageButton) findViewById(R.id.btnSendMsg);
if(s.length() > 0) {
btnSend.setEnabled(true);
} else {
btnSend.setEnabled(false);
}
}
示例15: 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();
}