EditText setText - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for EditText setText method.

This code example shows how to use the following methods:setSelection, setText
        super.onResume(); 
 
        SharedPreferences prefs = getPreferences(0); 
        String restoredText = prefs.getString("text", null);
        if (restoredText != null) {
            mSaved.setText(restoredText, TextView.BufferType.EDITABLE);
 
            int selectionStart = prefs.getInt("selection-start", -1);
            int selectionEnd = prefs.getInt("selection-end", -1);
            if (selectionStart != -1 && selectionEnd != -1) {
                mSaved.setSelection(selectionStart, selectionEnd);
            } 
        } 
    } 
 
    /** 
     * Any time we are paused we need to save away the current state, so it 
     * will be restored correctly when we are resumed. 
     */ 
    @Override 
6
CodeRank
This code example shows how to use the following methods:setText, addTextChangedListener, setView
import net.miginfocom.layout.IDEUtil; 
 
public class ComponentResizer { 
    public static void openResizer(final View view){
        final MigLayout.LayoutParams oldParams = (MigLayout.LayoutParams) view.getLayoutParams();
        final EditText input = new EditText(view.getContext());
        input.setText(oldParams.getConstraintString());
        final AlertDialog alert = new AlertDialog.Builder(view.getContext())
            .setTitle("Update Layout")
            .setView(input)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (view.getLayoutParams() != oldParams) {
                    view.setLayoutParams(oldParams);
                } 
            } 
        }).show();
        input.addTextChangedListener(new TextWatcher() {

6
CodeRank
This code example shows how to use the following methods:setText, setInputType, setView
		outState.putCharSequence("content", input.getText());
	} 
 
	@Override 
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		input = new EditText(getActivity());
		String message = getArguments().getString("title");
		CharSequence content;
		if (savedInstanceState == null) {
			content = getArguments().getCharSequence("content");
		} else { 
			content = savedInstanceState.getCharSequence("content");
		} 
		input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
		input.setText(content, TextView.BufferType.SPANNABLE);
		return new AlertDialog.Builder(getActivity())
				.setTitle(message)
				.setView(input)
				.setPositiveButton(getResources().getText(android.R.string.ok), new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {

6
CodeRank
This code example shows how to use the following methods:setText, setEnabled
		if(dialog instanceof DefaultValuesDialog){
			DefaultValuesDialog dia = (DefaultValuesDialog)dialog;
			if(dia.getSaved()){
				AppUtils utils = new AppUtils(XPArenaActivity.this);
				editURL.setText(utils.getDefaultXPURL());
				editUsername.setText(utils.getDefXPUser());
				editPassword.setText(utils.getDefXPPass());
				editUsername.setEnabled(false);
				editPassword.setEnabled(false);	
			}else{ 
				cbDefault.setChecked(false);
			} 
		} 
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:setText, setHint
 
        alert.setTitle(localizer.getString("prefsShareEmailTitle"));
        // alert.setMessage("Message"); 
 
        // Set an EditText view to get user input 
        final EditText input = new EditText(this);
        input.setHint(localizer.getString("prefsShareEmailHint"));
        input.setText(KeypadMapperApplication.getInstance().getSettings().getLastSharedEmail());
        alert.setView(input);
 
        alert.setPositiveButton(localizer.getString("prefsShareEmailShare"),
                new DialogInterface.OnClickListener() {
                    @Override 
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String email = input.getText().toString();
                        KeypadMapperApplication.getInstance().getSettings() 
                                .setLastSharedEmail(email);
                        shareFiles(componentName, email);
                        finish();
                    } 
5
CodeRank
This code example shows how to use the following methods:setText
		Cursor c = helper.getById(recipeId);
 
		c.moveToFirst();
		recipeName.setText(helper.getName(c));
		ingredient1.setText(helper.getIngredient(c, 1));
		ingredient2.setText(helper.getIngredient(c, 2));
		ingredient3.setText(helper.getIngredient(c, 3));
		direction1.setText(helper.getDirections(c));
 
		String type = helper.getType(c);
		Log.e("Test", helper.getType(c));
		if( type.contains(breakfast.getText().toString())){
			breakfast.setChecked(true);
		} 
		if( type.contains(lunch.getText().toString())){
			lunch.setChecked(true);
		} 
		if(type.contains(dinner.getText().toString())){
			dinner.setChecked(true);
		} 
4
CodeRank

Related EditText setText Questions & Answers:

setText Method Overview
Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
See Code Examples for other Android EditText Methods: