本文整理匯總了Java中android.text.Editable.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java Editable.clear方法的具體用法?Java Editable.clear怎麽用?Java Editable.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.Editable
的用法示例。
在下文中一共展示了Editable.clear方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromUser
import android.text.Editable; //導入方法依賴的package包/類
/**
* Creates a SafeHelperFactory from an Editable, such as what you get by
* calling getText() on an EditText.
*
* The Editable will be cleared as part of this call.
*
* @param editor the user's supplied passphrase
* @return a SafeHelperFactory
*/
public static SafeHelperFactory fromUser(Editable editor) {
char[] passphrase=new char[editor.length()];
SafeHelperFactory result;
editor.getChars(0, editor.length(), passphrase, 0);
try {
result=new SafeHelperFactory(passphrase);
}
finally {
editor.clear();
}
return(result);
}
示例2: 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();
}
示例3: applyMask
import android.text.Editable; //導入方法依賴的package包/類
private void applyMask(Editable text) {
if (TextUtils.isEmpty(text) || !hasMask()) {
return;
}
//remove input filters to ignore input type
InputFilter[] filters = text.getFilters();
text.setFilters(new InputFilter[0]);
int maskLen = mask.length();
int textLen = text.length();
int i = 0;
int notSymbolIndex = 0;
StringBuilder sb = new StringBuilder();
while (i < maskLen && notSymbolIndex < textLen) {
if (mask.charAt(i) == text.charAt(notSymbolIndex) || mask.charAt(i) == REPLACE_CHAR) {
sb.append(text.charAt(notSymbolIndex));
notSymbolIndex++;
} else {
sb.append(mask.charAt(i));
}
i++;
}
text.clear();
text.append(sb.toString());
//reset filters
text.setFilters(filters);
}
示例4: rekey
import android.text.Editable; //導入方法依賴的package包/類
/**
* Changes the passphrase associated with this database. The supplied
* Editable is cleared as part of this operation.
*
* @param editor source of passphrase, presumably from a user
*/
public void rekey(Editable editor) {
char[] passphrase=new char[editor.length()];
editor.getChars(0, editor.length(), passphrase, 0);
try {
rekey(passphrase);
}
finally {
editor.clear();
}
}
示例5: setupMaleFemaleAutocomplete
import android.text.Editable; //導入方法依賴的package包/類
private void setupMaleFemaleAutocomplete() {
EditText edit = (EditText) findViewById(R.id.topbar);
float elevation = 6f;
Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
AutocompletePresenter<User> presenter = new MaleFemalePresenter(this);
AutocompleteCallback<User> callback = new AutocompleteCallback<User>() {
@Override
public boolean onPopupItemClicked(Editable editable, User item) {
editable.clear();
editable.append(item.getFullname())
.append(" ")
.append(item.isFemale() ? "(Female)" : "(Male)");
editable.setSpan(new StyleSpan(Typeface.BOLD), 0, item.getFullname().length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return true;
}
public void onPopupVisibilityChanged(boolean shown) {}
};
maleFemaleAutocomplete = Autocomplete.<User>on(edit)
.with(elevation)
.with(backgroundDrawable)
.with(presenter)
.with(callback)
.build();
}
示例6: 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;
}
示例7: afterTextChanged
import android.text.Editable; //導入方法依賴的package包/類
@Override
public void afterTextChanged(final Editable s) {
// workaround for German keyboards
final String original = s.toString();
final String replaced = original.replace(',', '.');
if (!replaced.equals(original)) {
s.clear();
s.append(replaced);
}
MonetarySpannable.applyMarkup(s, null, MonetarySpannable.STANDARD_SIGNIFICANT_SPANS,
MonetarySpannable.STANDARD_INSIGNIFICANT_SPANS);
}