本文整理汇总了Java中android.text.Editable.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Editable.toString方法的具体用法?Java Editable.toString怎么用?Java Editable.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Editable
的用法示例。
在下文中一共展示了Editable.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemSelected
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
{
String timeSpanType = (String) parent.getItemAtPosition(pos);
Editable text = timeSpanEditText.getText();
if (text == null)
{
return;
}
String timeSpanAmountString = text.toString();
int timeSpanAmount = 0;
if (timeSpanAmountString != null && !"".equals(timeSpanAmountString))
{
timeSpanAmount = Integer.parseInt(timeSpanAmountString);
}
this.timeSpan = calculateTimeSpan(this.context, timeSpanType, timeSpanAmount);
}
示例2: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
String str = s.toString();
if (str.length() >= MIN_LENGTH_TO_LOOKUP) {
exampleView.setVisibility(View.GONE);
if (issuerListAdapter.getFullCount() == 0) {
if (lookupAsyncTask != null) {
lookupAsyncTask.cancel(true);
}
lookupAsyncTask = new GiroPayLookUpASyncTask(str);
lookupAsyncTask.execute();
} else {
issuerListAdapter.filter(str);
issuerListAdapter.notifyDataSetChanged();
}
} else {
exampleView.setVisibility(View.VISIBLE);
loadingView.setVisibility(View.GONE);
if (lookupAsyncTask != null) {
lookupAsyncTask.cancel(true);
}
issuerListAdapter.clearData();
issuerListAdapter.notifyDataSetChanged();
}
}
示例3: verifyAndSavePassphrases
import android.text.Editable; //导入方法依赖的package包/类
private void verifyAndSavePassphrases() {
Editable originalText = this.originalPassphrase.getText();
Editable newText = this.newPassphrase.getText();
Editable repeatText = this.repeatPassphrase.getText();
String original = (originalText == null ? "" : originalText.toString());
String passphrase = (newText == null ? "" : newText.toString());
String passphraseRepeat = (repeatText == null ? "" : repeatText.toString());
if (TextSecurePreferences.isPasswordDisabled(this)) {
original = MasterSecretUtil.UNENCRYPTED_PASSPHRASE;
}
if (!passphrase.equals(passphraseRepeat)) {
this.newPassphrase.setText("");
this.repeatPassphrase.setText("");
this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_passphrases_dont_match_exclamation));
this.newPassphrase.requestFocus();
} else if (passphrase.equals("")) {
this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation));
this.newPassphrase.requestFocus();
} else {
new ChangePassphraseTask(this).execute(original, passphrase);
}
}
示例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: submitOrder
import android.text.Editable; //导入方法依赖的package包/类
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
// Get user's name
EditText nameField = (EditText) findViewById(R.id.name_field);
Editable nameEditable = nameField.getText();
String name = nameEditable.toString();
// Figure out if the user wants whipped cream topping
CheckBox whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
// Figure out if the user wants choclate topping
CheckBox chocolateCheckBox = (CheckBox) findViewById(R.id.chocolate_checkbox);
boolean hasChocolate = chocolateCheckBox.isChecked();
// Calculate the price
int price = calculatePrice(hasWhippedCream, hasChocolate);
// Display the order summary on the screen
String message = createOrderSummary(name, price, hasWhippedCream, hasChocolate);
// Use an intent to launch an email app.
// Send the order summary in the email body.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT,
getString(R.string.order_summary_email_subject, name));
intent.putExtra(Intent.EXTRA_TEXT, message);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
开发者ID:ItalianCoder,项目名称:Google-Developer-Challenge-Scholarship-Android-Basics,代码行数:36,代码来源:MainActivity.java
示例6: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
String text = s.toString();
if (text.length() != 0 && !text.equals("")) {
mCurrentMoves = Integer.valueOf(s.toString());
}
}
示例7: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(final Editable s) {
mQuery = s.toString();
if (mQuery.isEmpty()) {
mSearchAlgorithm.cancel(true);
mCb.clearSearchResult();
} else {
mSearchAlgorithm.cancel(false);
mSearchAlgorithm.doSearch(mQuery, mCb);
}
}
示例8: sendMessage
import android.text.Editable; //导入方法依赖的package包/类
private void sendMessage()
{
if (messageEditText != null)
{
final String message;
Editable text = messageEditText.getText();
if (text == null)
{
return;
}
message = text.toString();
if (!Util.isNullOrWhiteSpace(message))
{
messageEditText.setText("");
BackgroundTask<Void> task = new TabActivityBackgroundTask<Void>(ChatActivity.this, false)
{
@Override
protected Void doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService(ChatActivity.this);
musicService.addChatMessage(message, ChatActivity.this, this);
return null;
}
@Override
protected void done(Void result)
{
load();
}
};
task.execute();
}
}
}
示例9: getTimeSpanAmount
import android.text.Editable; //导入方法依赖的package包/类
public int getTimeSpanAmount()
{
Spinner timeSpanSpinner = (Spinner) dialog.findViewById(R.id.timeSpanSpinner);
if (timeSpanSpinner == null)
{
return -1;
}
Editable text = timeSpanEditText.getText();
String timeSpanAmountString = null;
if (text != null)
{
timeSpanAmountString = text.toString();
}
int timeSpanAmount = 0;
if (timeSpanAmountString != null && !"".equals(timeSpanAmountString))
{
timeSpanAmount = Integer.parseInt(timeSpanAmountString);
}
return timeSpanAmount;
}
示例10: getTimeSpanFromDialog
import android.text.Editable; //导入方法依赖的package包/类
public static TimeSpan getTimeSpanFromDialog(Context context, View dialog)
{
EditText timeSpanEditText = (EditText) dialog.findViewById(R.id.timeSpanEditText);
Spinner timeSpanSpinner = (Spinner) dialog.findViewById(R.id.timeSpanSpinner);
if (timeSpanEditText == null || timeSpanSpinner == null)
{
return new TimeSpan(-1);
}
String timeSpanType = (String) timeSpanSpinner.getSelectedItem();
Editable text = timeSpanEditText.getText();
String timeSpanAmountString = null;
if (text != null)
{
timeSpanAmountString = text.toString();
}
int timeSpanAmount = 0;
if (timeSpanAmountString != null && !"".equals(timeSpanAmountString))
{
timeSpanAmount = Integer.parseInt(timeSpanAmountString);
}
return calculateTimeSpan(context, timeSpanType, timeSpanAmount);
}
示例11: onMentionKeyArrived
import android.text.Editable; //导入方法依赖的package包/类
@Override
public boolean onMentionKeyArrived(RichEditText editText) {
Editable msg = editText.getText();
String msgStr = msg.toString();
if (TextUtils.isEmpty(msgStr))
return false;
int selStartIndex = editText.getSelectionStart();
if (TextUtils.isEmpty(msgStr.trim()) || selStartIndex <= 0
|| TextUtils.isEmpty(msgStr.substring(selStartIndex - 1, selStartIndex).trim())) {
skipMention(editText);
}
return true;
}
示例12: handlePassphrase
import android.text.Editable; //导入方法依赖的package包/类
private void handlePassphrase() {
try {
Editable text = passphraseText.getText();
String passphrase = (text == null ? "" : text.toString());
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
setMasterSecret(masterSecret);
} catch (InvalidPassphraseException ipe) {
passphraseText.setText("");
passphraseText.setError(
getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
}
}
示例13: onTopicKeyArrived
import android.text.Editable; //导入方法依赖的package包/类
@Override
public boolean onTopicKeyArrived(RichEditText editText) {
Editable msg = editText.getText();
String msgStr = msg.toString();
int selStartIndex = editText.getSelectionStart();
int selEndIndex = editText.getSelectionEnd();
if (TextUtils.isEmpty(msgStr.trim()) || selStartIndex <= 0) {
skipTopic(editText);
return true;
}
int startIndex = 0;
RichEditText.TagSpan[] spans = msg.getSpans(0, selStartIndex, RichEditText.TagSpan.class);
if (spans.length > 0) {
startIndex = msg.getSpanEnd(spans[spans.length - 1]);
}
boolean isMatcher = false;
String tagStr = msgStr.substring(startIndex, selStartIndex) + "#";
Pattern pattern = Pattern.compile(RichEditText.MATCH_TOPIC);
Matcher matcher = pattern.matcher(tagStr);
while (matcher.find()) {
String str = matcher.group();
int matcherStart = matcher.start() + startIndex;
int matcherEnd = matcher.end() + startIndex;
if (matcherEnd == selStartIndex + 1)
msg.replace(selStartIndex, selEndIndex, "#");
msg.setSpan(new RichEditText.TagSpan(str), matcherStart, matcherEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
isMatcher = true;
}
if (isMatcher) {
editText.setSelection(selEndIndex);
return false;
}
skipTopic(editText);
return true;
}
示例14: backspace
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void backspace() {
final int selectionHandle = getSelectionStart();
final Editable editable = getText();
if (selectionHandle > 0) {
MathSpannable[] spans = editable.getSpans(selectionHandle, selectionHandle, MathSpannable.class);
if (spans.length != 0) {
String text = editable.toString();
String textBeforeInsertionHandle = text.substring(0, selectionHandle);
String textAfterInsertionHandle = text.substring(selectionHandle, text.length());
int deletionLength = -1;
if (selectionHandle == editable.getSpanEnd(spans[0]) && spans[0].removeOnBackspace()) {
deletionLength = spans[0].getEquation().length();
} else if (selectionHandle != editable.getSpanStart(spans[0])) {
deletionLength = spans[0].backspace();
}
if (deletionLength != -1) {
String newText = textBeforeInsertionHandle.substring(0, textBeforeInsertionHandle.length() - deletionLength) + textAfterInsertionHandle;
setText(newText);
setSelection(selectionHandle - deletionLength);
return;
}
}
}
super.backspace();
}
示例15: afterTextChanged
import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
String text = s.toString();
MotionEntity entity = getSelectedEntity();
if (entity != null && entity instanceof TextEntity) {
TextEntity textEntity = (TextEntity)entity;
if (!textEntity.getLayer().getText().equals(text)) {
textEntity.getLayer().setText(text);
textEntity.updateEntity();
MotionView.this.invalidate();
}
}
}