当前位置: 首页>>代码示例>>Java>>正文


Java EditText.getText方法代码示例

本文整理汇总了Java中android.widget.EditText.getText方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.getText方法的具体用法?Java EditText.getText怎么用?Java EditText.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSpace

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 添加间隔
 *
 * @param ed        EditText
 * @param maxLength 有效位数 比如 电话11位
 * @param location  要打间隔的位置
 */
private void addSpace(EditText ed, int maxLength, int... location) {
    Editable s = ed.getText();
    String val = s.toString();
    String valRep = val.replace(" ", "");
    StringBuilder sb = new StringBuilder(valRep);
    for (int m = 0; m < location.length; m++) {
        if (sb.length() > location[m] + m) {
            sb.insert(location[m] + m, " ");
        }
    }
    if (sb.length() > maxLength + location.length) {
        String _s = sb.toString().substring(0, maxLength + location.length);
        ed.setText(_s);
        ed.setSelection(_s.length());
    } else {
        int k = mContent.getSelectionEnd();
        ed.setText(sb);
        ed.setSelection(isSelection ? k : sb.length());
    }
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:28,代码来源:EditTextWatcher.java

示例2: submitOrder

import android.widget.EditText; //导入方法依赖的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

示例3: domainFieldValid

import android.widget.EditText; //导入方法依赖的package包/类
public static boolean domainFieldValid(EditText view) {
    if (view.getText() != null) {
        String s = view.getText().toString();
        if (s.matches("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)*[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?$") &&
            s.length() <= 253) {
            return true;
        }
        if (s.matches("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")) {
            return true;
        }
    }
    return false;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:14,代码来源:Utility.java

示例4: getCommonEmoticonClickListener

import android.widget.EditText; //导入方法依赖的package包/类
public static EmoticonClickListener getCommonEmoticonClickListener(final EditText editText) {
        return new EmoticonClickListener() {
            @Override
            public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
                if (isDelBtn) {
                    PublishUtils.delClick(editText);
                } else {
                    if (o == null) {
                        return;
                    }
                    if (actionType == Constants.EMOTICON_CLICK_TEXT) {
                        String content = null;
//                        if (o instanceof EmojiBean) {
//                            content = ((EmojiBean) o).emoji;
//                        } else
                        if (o instanceof EmoticonEntity) {
                            content = ((EmoticonEntity) o).getContent();
                        }

                        if (TextUtils.isEmpty(content)) {
                            return;
                        }
                        int index = editText.getSelectionStart();
                        Editable editable = editText.getText();
                        editable.insert(index, content);
                    }
                }
            }
        };
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:PublishUtils.java

示例5: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_detail);

    // Get post key from intent
    mPostKey = getIntent().getStringExtra(EXTRA_POST_KEY);
    if (mPostKey == null) {
        throw new IllegalArgumentException("Must pass EXTRA_POST_KEY");
    }

    // Initialize Database
    mPostReference = FirebaseDatabase.getInstance().getReference()
            .child("posts").child(mPostKey);
    mCommentsReference = FirebaseDatabase.getInstance().getReference()
            .child("post-comments").child(mPostKey);

    // Initialize Views
    mAuthorView = (TextView) findViewById(R.id.post_author);
    mTitleView = (TextView) findViewById(R.id.post_title);
    mBodyView = (TextView) findViewById(R.id.post_body);
    mCommentField = (EditText) findViewById(R.id.field_comment_text);
    mCommentButton = (ImageButton) findViewById(R.id.button_post_comment);
    mCommentButton.setEnabled(false);
    if (mCommentField.getText() != null){
        mCommentButton.setEnabled(true);
        mCommentButton.setImageResource(R.drawable.ic_foursquare_button);
    }
    mCommentsRecycler = (RecyclerView) findViewById(R.id.recycler_comments);
    detailedPicture = (ImageView)findViewById(R.id.post_author_photo);
    mCommentButton.setOnClickListener(this);
    mCommentsRecycler.setLayoutManager(new LinearLayoutManager(this));
    authorImage = (ImageView)findViewById(R.id._author_photo);
    authorName = (TextView)findViewById(R.id.author_name);
    authorJob = (TextView)findViewById(R.id.author_job_title);
    aboutTheAuthor = (TextView)findViewById(R.id.author_description_);
    numberOfParticipants = (TextView)findViewById(R.id.number_of_participants);
    timeStampText = (TextView)findViewById(R.id.the_real_fucking_time);

}
 
开发者ID:braulio94,项目名称:Quadro,代码行数:41,代码来源:PostDetailActivity.java

示例6: getTimeSpanFromDialog

import android.widget.EditText; //导入方法依赖的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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:30,代码来源:TimeSpanPicker.java

示例7: getCommonEmoticonClickListener

import android.widget.EditText; //导入方法依赖的package包/类
public static EmoticonClickListener getCommonEmoticonClickListener(final EditText editText) {
    return new EmoticonClickListener() {
        @Override
        public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
            if (isDelBtn) {
                delClick(editText);
            } else {
                if (o == null) {
                    return;
                }
                if (actionType == Constants.EMOTICON_CLICK_TEXT) {
                    String content = null;
                    if (o instanceof EmojiBean) {
                        content = ((EmojiBean) o).emoji;
                    } else if (o instanceof EmoticonEntity) {
                        content = ((EmoticonEntity) o).getContent();
                    }

                    if (TextUtils.isEmpty(content)) {
                        return;
                    }
                    int index = editText.getSelectionStart();
                    Editable editable = editText.getText();
                    editable.insert(index, content);
                }
            }
        }
    };
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:30,代码来源:ExpressionCommonUtils.java

示例8: searchByMaterialName

import android.widget.EditText; //导入方法依赖的package包/类
public void searchByMaterialName(View view) {
    EditText editTextDensity = (EditText) findViewById(R.id.editTextDensity);
    EditText editTextEnergy = (EditText) findViewById(R.id.editTextEnergy);
    EditText editTextDistance = (EditText) findViewById(R.id.editTextEditDistance);
    TextView textViewResult = (TextView) findViewById(R.id.textViewIDCalcAttnResult);
    if(editTextEnergy.getText()==null || editTextDensity.getText()==null || editTextDistance.getText()==null){
        textViewResult.setText("Must enter a value first");
        return;
    }
    try {
        fEnergy = Double.parseDouble(editTextEnergy.getText().toString());
        fDensity = Double.parseDouble(editTextDensity.getText().toString());
        fDistance = Double.parseDouble(editTextDistance.getText().toString());
    }
    catch (NumberFormatException e){
        textViewResult.setText("Must enter a value first");
        return;
    }

    if(fEnergy>=0.001&&fEnergy<=20){
        int i;
        double fCoeffInterp = 0;
        for(i=0; i<fEnergyList.length; i++){
            if(fEnergy == fEnergyList[i]){
                fCoeffInterp = fCoeffList[i];
                break;
            }
            if(fEnergy<fEnergyList[i]){
                fCoeffInterp = fCoeffList[i-1] + (fEnergy-fEnergyList[i-1])*(fCoeffList[i]-fCoeffList[i-1])/(fEnergyList[i]-fEnergyList[i-1]);
                break;
            }
        }
        textViewResult.setText(Double.toString(Math.exp(-fCoeffInterp*fDensity*fDistance)*100));
    }
    else{
        textViewResult.setText("Invalid energy range (0.001 to 20)");
    }
}
 
开发者ID:JW1992,项目名称:NISTGammaSearch,代码行数:39,代码来源:CalcAttenuationActivity.java

示例9: insertAtCursor

import android.widget.EditText; //导入方法依赖的package包/类
private static int insertAtCursor(EditTextSelectionState selectionState,
                                  CharSequence textToInsert) {
    EditText editText = selectionState.getEditText();
    Editable editable = editText.getText();
    int editableLen = editable.length();
    int selStart = selectionState.getSelectionStart();
    int selEnd = selectionState.getSelectionEnd();
    int start = (selStart >= 0) ? selStart : editableLen-1;
    int end = (selEnd >= 0) ? selEnd : editableLen-1;
    editable.replace(Math.min(start, end), Math.max(start, end),
            textToInsert, 0, textToInsert.length());
    return Math.min(start, end);
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:14,代码来源:EditTextUtils.java

示例10: getString

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * Get string from edittext
 *
 * @param e The edittext
 * @return the string from edittext, null in all other cases
 */
@Nullable
public static String getString(@Nullable EditText e) {
    if (e == null) {
        return null;
    }
    if (e.getText() == null) {
        return null;
    }
    return getString(e.getText().toString());
}
 
开发者ID:yajnesh,项目名称:AndroidGeneralUtils,代码行数:17,代码来源:GenericUtil.java

示例11: onShareClick

import android.widget.EditText; //导入方法依赖的package包/类
public void onShareClick(View view) {
    EditText editText = (EditText) findViewById(R.id.edit_text);
    if (editText != null) {
        CharSequence shareContent = editText.getText();
        AppChooser.from(this).text(shareContent.toString()).excluded(mComponentNames).load();
    }
}
 
开发者ID:JulianAndroid,项目名称:AppChooser,代码行数:8,代码来源:ShareActivity.java

示例12: onNextButtonClick

import android.widget.EditText; //导入方法依赖的package包/类
@ActionHandler(layoutResource = R.id.next_button)
public void onNextButtonClick(View v){
    EditText passwordEditText       = (EditText)findViewById(R.id.password);
    EditText passwordConfirm1       = (EditText)findViewById(R.id.password_confirm);
    EditText usernameEdit           = (EditText)findViewById(R.id.username_edittext);

    String errorMessageLength       = "password length should be greater than 3";
    String errorMessageMatch        = "password does not match";
    CharSequence sequence           = passwordEditText.getText();
    CharSequence sequenceConfirm    = passwordConfirm1.getText();

    if(usernameEdit.getText().toString().length()<1){
        usernameEdit.setError("Please give me your name");
        return;
    }
    mUserName=usernameEdit.getText().toString();
    if(isValidPassword(sequence)){
        if(sequence.toString().equals(sequenceConfirm.toString())) {
            mUserSecretDatabase=sequence.toString();
                Boolean permission=checkPermissions();
                if(permission){
                    new DatabaseSetupTask().execute();
                }

            }else{
                passwordConfirm1.setError(errorMessageMatch);
            }
        }else{
            passwordEditText.setError(errorMessageLength);
        }

}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:33,代码来源:InitActivity.java

示例13: isEmpty

import android.widget.EditText; //导入方法依赖的package包/类
public static boolean isEmpty(EditText value) {
  return value == null || value.getText() == null || TextUtils.isEmpty(value.getText().toString());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:4,代码来源:Util.java

示例14: validateNotEmpty

import android.widget.EditText; //导入方法依赖的package包/类
public static boolean validateNotEmpty(EditText textField) {
    return textField != null && textField.getText()!=null && !textField.getText().toString().isEmpty();
}
 
开发者ID:joaomneto,项目名称:TitanCompanion,代码行数:4,代码来源:AdventureTools.java

示例15: PerformInputAfter

import android.widget.EditText; //导入方法依赖的package包/类
private PerformInputAfter(@NonNull EditText editText) {
    Check.CheckNull(editText, "EditText不能为空");
    editable = editText.getText();
    editText.addTextChangedListener(new Watcher());
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:6,代码来源:PerformInputAfter.java


注:本文中的android.widget.EditText.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。