Example usage for android.widget EditText EditText

List of usage examples for android.widget EditText EditText

Introduction

In this page you can find the example usage for android.widget EditText EditText.

Prototype

public EditText(Context context) 

Source Link

Usage

From source file:cc.softwarefactory.lokki.android.utilities.DialogUtils.java

public static void addContact(final Context context) {

    final EditText input = new EditText(context); // Set an EditText view to get user input
    input.setSingleLine(true);/*w w w . j av a  2  s . c  o m*/
    input.setHint(R.string.contact_email_address);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);

    final AlertDialog addContactDialog = new AlertDialog.Builder(context)
            .setTitle(context.getResources().getString(R.string.add_contact)).setView(input)
            .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create();

    addContactDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

            addContactDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                    .setOnClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View view) {
                            Editable value = input.getText();
                            if (value == null || value.toString().isEmpty()) {
                                input.setError(context.getResources().getString(R.string.required));
                                return;
                            }

                            String email = value.toString();

                            try {
                                ServerApi.allowPeople(context, email);
                                Toast.makeText(context, R.string.contact_added, Toast.LENGTH_SHORT).show();
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            addContactDialog.dismiss();
                        }
                    });
        }
    });

    addContactDialog.show();
}

From source file:com.mifos.mifosxdroid.formwidgets.FormEditText.java

public FormEditText(Context context, String name) {

    super(context, name);
    label = new TextView(context);
    label.setText(getDisplayText());/*from  w w  w .j  ava 2s  . co m*/
    label.setLayoutParams(FormWidget.defaultLayoutParams);

    input = new EditText(context);
    input.setLayoutParams(FormWidget.defaultLayoutParams);
    input.setImeOptions(EditorInfo.IME_ACTION_DONE);
    isDateAvailable = false;
    layout.addView(label);
    layout.addView(input);

}

From source file:com.cachirulop.moneybox.common.PromptDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder;/*from   www . j a v  a 2 s . c  o  m*/

    _input = new EditText(getActivity());

    builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(_titleId);
    builder.setMessage(_messageId);
    builder.setView(_input);

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Do nothing here because we
            // override this button later to
            // change the close behaviour.
            // However, we still need this
            // because on older versions of
            // Android unless we
            // pass a handler the button doesn't
            // get instantiated
        }
    });

    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}

From source file:gov.in.bloomington.georeporter.fragments.PersonalInfoFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    final String fieldname = PersonalInfoAdapter.FIELDS[position];
    final TextView label = (TextView) v.findViewById(android.R.id.text1);
    final TextView input = (TextView) v.findViewById(android.R.id.text2);

    final EditText newValue = new EditText(getActivity());
    newValue.setText(input.getText());// w ww  .  j  a v a2  s .  co m

    int type = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
    if (fieldname == "email") {
        type = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
    }
    if (fieldname == "phone") {
        type = InputType.TYPE_CLASS_PHONE;
    }
    newValue.setInputType(type);

    new AlertDialog.Builder(getActivity()).setTitle(label.getText()).setView(newValue)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        mPersonalInfo.put(fieldname, newValue.getText());
                    } catch (JSONException e) {
                        // Just ignore any errors
                    }
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Do Nothing
                }
            }).show();
}

From source file:com.baasbox.android.samples.aloa.activities.CreateChannelFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final EditText input = new EditText(getActivity());
    builder.setTitle(getString(R.string.create_channel));
    builder.setMessage(getString(R.string.create_channel_message));
    builder.setView(input);/*from  w ww  .ja va  2s .c om*/
    final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                String ch = input.getText().toString();
                if (listener != null && !TextUtils.isEmpty(ch)) {
                    listener.onTargetSelected(ch, true);
                }
            }
        }
    };
    builder.setPositiveButton(android.R.string.ok, clickListener);
    builder.setNegativeButton(android.R.string.cancel, clickListener);
    return builder.create();
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Dialogs.TextDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    input = new EditText(getActivity());
    String message = getArguments().getString("title");
    CharSequence content;// w w  w  .ja v a2 s  .com
    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) {
                            doPositiveClick();
                        }
                    })
            .setNegativeButton(getResources().getText(android.R.string.cancel),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            doNegativeClick();
                        }
                    })
            .setOnKeyListener(new DialogInterface.OnKeyListener() {

                @Override
                public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                    if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) && (i == KeyEvent.KEYCODE_ENTER)) {
                        dialogInterface.dismiss();
                        doPositiveClick();
                        return true;
                    }
                    return false;
                }
            }).create();
}

From source file:com.dnielfe.manager.dialogs.UnpackDialog.java

@Override
public Dialog onCreateDialog(Bundle state) {
    final Activity a = getActivity();

    // Set an EditText view to get user input
    final EditText inputf = new EditText(a);
    inputf.setHint(R.string.enter_name);
    inputf.setText(Browser.mCurrentPath);

    final AlertDialog.Builder b = new AlertDialog.Builder(a);
    b.setTitle(R.string.extractto);//from  ww w .j  a v a2s  .  c  om
    b.setView(inputf);
    b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String newpath = inputf.getText().toString();

            dialog.dismiss();

            if (ext.equals("zip")) {
                final UnZipTask task = new UnZipTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            } else if (ext.equals("rar")) {
                final UnRarTask task = new UnRarTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            }
        }
    });
    b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return b.create();
}

From source file:com.lovejoy777sarootool.rootool.dialogs.UnpackDialog.java

@Override
public Dialog onCreateDialog(Bundle state) {
    final Activity a = getActivity();

    // Set an EditText view to get user input
    final EditText inputf = new EditText(a);
    inputf.setHint(R.string.enter_name);
    inputf.setText(BrowserActivity.getCurrentlyDisplayedFragment().mCurrentPath + "/");

    final AlertDialog.Builder b = new AlertDialog.Builder(a);
    b.setTitle(R.string.extractto);//from  w w  w.j a v a  2s. co  m
    b.setView(inputf);
    b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String newpath = inputf.getText().toString();

            dialog.dismiss();

            if (ext.equals("zip")) {
                final UnZipTask task = new UnZipTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            } else if (ext.equals("rar")) {
                final UnRarTask task = new UnRarTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            }
        }
    });
    b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return b.create();
}

From source file:com.bt.download.android.gui.adapters.menu.RenameFileMenuAction.java

@Override
protected void onClick(Context context) {
    String filePath = fd.filePath;

    String name = FilenameUtils.getBaseName(filePath);
    final String ext = FilenameUtils.getExtension(filePath);

    final EditText input = new EditText(context);
    input.setText(name);// w w w .  ja  v  a2 s  . c o  m
    input.selectAll();

    UIUtils.showOkCancelDialog(context, input, R.string.rename, new OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String newFileName = input.getText().toString() + "." + ext;
            if (isValidFileName(newFileName)) {
                renameFile(newFileName);
                adapter.notifyDataSetChanged();
            } else {
                // FIXME
            }
        }
    });
}