本文整理匯總了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();
}
}