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:com.marvin.rocklock.PlaylistFragment.java

/**
 * Switches to playlist build mode and prompts user for playlist name
 *///  w  w  w  .j  a v  a2  s. c o  m
private void buildPlaylist() {

    AlertDialog.Builder alert = new AlertDialog.Builder(mParent);
    alert.setTitle(getString(R.string.new_playlist));
    // TODO(sainsley): add default name based on
    // number of playlists in directory
    alert.setMessage(getString(R.string.enter_playlist_name));

    final EditText input = new EditText(mParent);
    alert.setView(input);

    alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            mPlaylistName = input.getText().toString();
            mBuildPlaylistMode = true;
            mPlaylistBuilder = new ArrayList<String>();
            mParent.speakAndDuck(getString(R.string.playlist_instructions), true);
            // Start out browsing songs
            mNavigator.setPickerMode(SongNavigator.MODE_TRACK);
            mNavigator.peekMode(0, false);
            mNavigator.speakCurrentTrack(false);
            updateText();

            return;
        }
    });

    alert.show();
}

From source file:com.javielinux.fragments.SearchGeneralFragment.java

public void searchIcon() {
    final EditText et = new EditText(getActivity());

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(this.getString(R.string.search_avatar));
    builder.setMessage(this.getString(R.string.search_avatar_msg));
    builder.setView(et);/*w  w w  .  j  a  v  a2s.com*/
    builder.setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            searchAvatarInTwitter(et.getText().toString());
        }

    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.developfreedom.ccdroid.app.ui.MainActivity.java

private void showAddUrlDialog() {
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    input.setText(preferences.getUrl());

    new AlertDialog.Builder(this).setMessage(R.string.dialog_message_add_url)
            .setTitle(R.string.dialog_title_add_url).setView(input)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override/*from ww w  .  j a  v a2 s. c  o  m*/
                public void onClick(DialogInterface dialog, int id) {
                    //TODO: Check input text to be a url
                    preferences.setUrl(input.getText().toString());
                }
            }).setNegativeButton(android.R.string.cancel, null).create().show();
}

From source file:com.seedform.dfatester.viewer.AlphabetListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final Character oldChar = mDFA.getAlphabet().get(position);
    final EditText input = new EditText(getActivity());
    input.setHint(getResources().getString(R.string.hint_concat_symbol_replacement) + "\"" + oldChar.toString()
            + "\"");
    input.setGravity(Gravity.CENTER);//from   w ww  .j  av a 2  s . c  om
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(1) });

    new AlertDialog.Builder(getActivity()).setTitle(R.string.title_symbol_replacement).setView(input)
            .setPositiveButton(R.string.action_replace_symbol, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String inputText = input.getText().toString();
                    String message;

                    if (inputText.length() != 0) {
                        if (mDFA.replaceSymbol(oldChar, inputText.charAt(0))) {
                            message = "\"" + oldChar + "\""
                                    + getResources().getString(R.string.msg_concat_symbol_replaced);
                            mAdapter.notifyDataSetChanged();
                        } else {
                            message = "\"" + inputText + "\""
                                    + getResources().getString(R.string.msg_concat_symbol_exists);
                        }
                        Tool.createToast(getActivity(), message, Toast.LENGTH_SHORT);
                    }
                }
            }).show();
}

From source file:com.gnufabio.costituzione.DetailedActivity.java

@SuppressWarnings("static-access")
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch (item.getItemId()) {

    case R.id.favourite_status:
        DatabaseHandler dbh = new DatabaseHandler(this);
        dbh.open(true);/*from  www. j a  v a2  s  . c  om*/
        mEntry.setIsFavourite(!mEntry.isFavourite());
        dbh.updateFavoriteStatus(mEntry);
        dbh.close();

        new Toast(this).makeText(this, mEntry.isFavourite() ? R.string.added_to_fav : R.string.removed_from_fav,
                Toast.LENGTH_LONG).show();
        updateFavoriteButton(item);
        break;
    case R.id.menu_edit_note:
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle(R.string.dialog_update_note);

        final EditText input = new EditText(this);
        String nota = mNote.getTesto();
        input.setText(nota.equalsIgnoreCase("@Null") ? "" : nota);
        alert.setView(input);

        alert.setPositiveButton(mContext.getResources().getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        int pos = vp.getCurrentItem();
                        String value = input.getText().toString();
                        NotesDatabaseHandler ndbh = new NotesDatabaseHandler(mContext);
                        ndbh.open(true);
                        mNote.setTesto(value);
                        ndbh.updateNote(mNote);
                        ndbh.close();
                        listNotes.remove(pos);
                        listNotes.add(pos, mNote);
                        DetailedFragmentAdapter adapter = (DetailedFragmentAdapter) vp.getAdapter();
                        adapter.getItem(pos).setNoteText(value);
                        adapter.updateNote(pos, mNote);
                        vp.setAdapter(adapter);
                        vp.setCurrentItem(pos, false);
                    }
                });

        alert.setNegativeButton(mContext.getResources().getString(android.R.string.cancel), null);
        alert.show();
        break;
    }
    return true;
}

From source file:de.tu_berlin.snet.commstat.EmailFragment.java

private void addAccount() {
    final EditText input = new EditText(getActivity());

    new AlertDialog.Builder(getActivity()).setTitle("Add Account")
            .setMessage(getString(R.string.add_account_message)).setView(input)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    list.add(input.getText().toString());
                    adapter.notifyDataSetChanged();
                    saveAccounts();//from   w w w.j  a  va 2  s.  c o  m
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                }
            }).show();
}

From source file:id.satusatudua.sigap.ui.fragment.SettingFragment.java

@OnClick(R.id.feedback)
public void onFeedbackClick() {
    EditText editText = new EditText(getActivity());
    editText.setHint("Feedback");
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).setIcon(R.mipmap.ic_launcher)
            .setTitle("Kirim Feedback").setView(editText).setPositiveButton("Kirim", (dialog, which) -> {
                if (!editText.getText().toString().isEmpty()) {
                    sendFeedBack(editText.getText().toString());
                    KeyboardUtil.hideKeyboard(getActivity(), editText);
                    dialog.dismiss();//w w w.jav  a  2  s .co  m
                }
            }).setNegativeButton("Batal", (dialog, which1) -> {
                dialog.dismiss();
            }).show();

    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)
            .setTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
            .setTextColor(ContextCompat.getColor(getActivity(), R.color.primary_text));
    alertDialog.show();
}

From source file:com.krayzk9s.imgurholo.ui.AlbumsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection
    Activity activity = getActivity();/*from w ww .  j av  a  2s  .  c  o m*/
    switch (item.getItemId()) {
    case R.id.action_refresh:
        urls = new ArrayList<String>();
        imageAdapter.notifyDataSetChanged();
        getImages();
        return true;
    case R.id.action_new:
        final EditText newTitle = new EditText(activity);
        newTitle.setSingleLine();
        newTitle.setHint(R.string.hint_album_title);
        final EditText newDescription = new EditText(activity);
        newDescription.setHint(R.string.body_hint_description);
        LinearLayout linearLayout = new LinearLayout(activity);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.addView(newTitle);
        linearLayout.addView(newDescription);
        new AlertDialog.Builder(activity).setTitle(R.string.dialog_new_album_title).setView(linearLayout)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        NewAlbumAsync messagingAsync = new NewAlbumAsync(newTitle.getText().toString(),
                                newDescription.getText().toString(),
                                ((ImgurHoloActivity) getActivity()).getApiCall(), null, null);
                        messagingAsync.execute();
                    }
                }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // Do nothing.
                    }
                }).show();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:cz.maresmar.sfm.app.SfmApp.java

/**
 * Opens email app with log file/*from   w  w w .ja va  2 s. c  o  m*/
 */
public void sendFeedback(Context context) {
    // Shows subjects dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.feedback_subject_title);
    builder.setMessage(R.string.feedback_subject_msg);

    // Set up the input
    final EditText input = new EditText(context);
    // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton(android.R.string.ok,
            (dialog, which) -> sendFeedback(context, input.getText().toString()));
    builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());

    builder.show();
}

From source file:com.inovex.zabbixmobile.activities.ServersActivity.java

private void openNewServerDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle(R.string.add_server);
    alert.setMessage("Type the name of the new server");

    // Set an EditText view to get user input
    final EditText input = new EditText(this);
    alert.setView(input);//from  w w  w.  j  a v  a 2 s.  co  m

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            if (value.length() > 0) {
                ZabbixServer server = mZabbixDataService.createNewZabbixServer(value);
                onServerSelected(server);
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
        }
    });

    alert.show();
}