本文整理汇总了Java中android.widget.EditText.append方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.append方法的具体用法?Java EditText.append怎么用?Java EditText.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.append方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: input
import android.widget.EditText; //导入方法依赖的package包/类
public static void input(EditText editText, String emoji) {
if (editText == null || TextUtils.isEmpty(emoji)) {
return;
}
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (start < 0) {
editText.append(emoji);
} else {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int length = getEditTextMaxLength(editText);
if(length>0 && start+emoji.length() > length){
return;
}
}
editText.getText().replace(Math.min(start, end), Math.max(start, end), emoji, 0, emoji.length());
if(editText.getText().length() < start+emoji.length()){
editText.getText().delete(Math.min(start, end), editText.getText().length());
}
}
}
示例2: input2OSC
import android.widget.EditText; //导入方法依赖的package包/类
public static void input2OSC(EditText editText, Emojicon emojicon) {
if (editText == null || emojicon == null) {
return;
}
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (start < 0) {
// 没有多选时,直接在当前光标处添加
editText.append(emojicon.getRemote());
} else {
// 将已选中的部分替换为表情(当长按文字时会多选刷中很多文字)
String str = emojicon.getRemote();
editText.getText().replace(Math.min(start, end),
Math.max(start, end), str, 0, str.length());
}
}
示例3: input2OSC
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 输入Emoji表情到 EditText
*
* @param editText EditText
* @param emojicon Emojicon
*/
public static void input2OSC(EditText editText, Emojicon emojicon) {
if (editText == null || emojicon == null) {
return;
}
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (start < 0) {
// 没有多选时,直接在当前光标处添加
editText.append(displayEmoji(editText.getResources(),
emojicon.getRemote(), (int) editText.getTextSize()));
} else {
// 将已选中的部分替换为表情(当长按文字时会多选刷中很多文字)
Spannable str = displayEmoji(editText.getResources(),
emojicon.getRemote(), (int) editText.getTextSize());
editText.getText().replace(Math.min(start, end),
Math.max(start, end), str, 0, str.length());
}
}
示例4: input
import android.widget.EditText; //导入方法依赖的package包/类
public static void input(EditText editText, Emojicon emojicon) {
if (editText == null || emojicon == null) {
return;
}
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (start < 0) {
editText.append(emojicon.getEmoji());
} else {
editText.getText().replace(Math.min(start, end), Math.max(start, end), emojicon.getEmoji(), 0, emojicon.getEmoji().length());
}
}
示例5: onClickSelectedWord
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onClickSelectedWord(String str) {
EditText txtInput = (EditText)findViewById(R.id.edtSmartMathInput);
int nSelectionStart = txtInput.getSelectionStart();
int nSelectionEnd = txtInput.getSelectionEnd();
if (str.length() > 0) {
// ensure that some text will be changed
String strInputLowerCase = txtInput.getText().toString().toLowerCase(Locale.US);
if (strInputLowerCase.trim().equals("help") // This should be first to avoid the case where string length = 0.
&& strInputLowerCase.charAt(strInputLowerCase.length() - 1) == ' ') {
// this is to input help.
String strTxt2InputProc = str.trim();
if (strTxt2InputProc.equals("(") == false) {
strTxt2InputProc = strTxt2InputProc.split("\\(")[0];
}
txtInput.append(strTxt2InputProc);
txtInput.setSelection(txtInput.getText().length());
minputMethod.clearInputBuffer();
} else {
txtInput.getText().replace(nSelectionStart, nSelectionEnd, str);
txtInput.setSelection(nSelectionStart + str.length());
minputMethod.clearInputBuffer();
// may need to move to another input pad.
String strTrimmed = str.trim();
if (strTrimmed.length() > 0
&& (strTrimmed.charAt(strTrimmed.length() - 1) == '(' || strTrimmed.charAt(strTrimmed.length() - 1) == '[')) {
int idx = 0;
for (TableInputPad inputPad : minputMethod.mlistShownInputPads) {
if (inputPad.mstrName.equals("numbers_operators")) {
minputMethod.showInputMethod(idx, true);
break;
}
idx ++;
}
}
}
} else {
// not in the editable area or nothing to input.
minputMethod.clearInputBuffer();
}
}