Example usage for android.widget EditText getText

List of usage examples for android.widget EditText getText

Introduction

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

Prototype

@Override
    public Editable getText() 

Source Link

Usage

From source file:adventure_fragments.Running.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);/*from  ww w  .j a v  a  2s.  co  m*/
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemRunning(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsRunning();
                adapt = new CustomAdapter4(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_run);
                listItem.setAdapter(adapt);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.show();
}

From source file:com.skalski.raspberrycontrol.Activity_RemoteControl.java

private AlertDialog makeAndShowDialogBox(final View Button) {

    final EditText setTag = new EditText(this);
    setTag.setText((String) Button.getTag());

    return new AlertDialog.Builder(this)

            .setTitle(getResources().getString(R.string.ir_msg_2))
            .setMessage(getResources().getString(R.string.ir_msg_1)).setView(setTag)

            .setPositiveButton(getResources().getString(R.string.com_msg_5),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {

                            String tag;
                            tag = setTag.getText().toString();

                            SharedPreferences sharedPreferences = PreferenceManager
                                    .getDefaultSharedPreferences(getBaseContext());
                            SharedPreferences.Editor Editor = sharedPreferences.edit();
                            Editor.putString("tag_" + Button.getId(), tag);
                            Editor.commit();
                            Button.setTag(tag);
                        }// w ww . j a  v a  2  s .  c  o  m
                    })

            .setNegativeButton(getResources().getString(R.string.com_msg_6),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        }
                    })

            .create();
}

From source file:adventure_fragments.Hiking.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);// w w w .  j  a v  a2  s . com
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemHiking(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsHiking();
                adapt = new CustomAdapter2(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_hike);
                listItem.setAdapter(adapt);

                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.show();
}

From source file:adventure_fragments.Kayaking.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);/*from  ww w  .  j a  v  a2 s. c  o m*/
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemKayaking(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsKayaking();
                adapt = new CustomAdapter3(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_kayak);
                listItem.setAdapter(adapt);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
}

From source file:adventure_fragments.Skiing.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);/*from w  ww. ja  v a2s.c  om*/
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemSkiing(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsSkiing();
                adapt = new CustomAdapter5(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_ski);
                listItem.setAdapter(adapt);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.show();
}

From source file:adventure_fragments.Swimming.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);/*from   w  w w . ja v  a2 s.co  m*/
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemSwimming(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsSwimming();
                adapt = new CustomAdapter6(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_swim);
                listItem.setAdapter(adapt);
                nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_swim);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.show();
}

From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java

private void renamePlaceDialog(final String placeName) {

    Log.d(TAG, "renamePlaceDialog");
    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
    final EditText input = new EditText(getActivity());
    String titleFormat = getResources().getString(R.string.rename_place);
    String title = String.format(titleFormat, placeName);

    dialog.setTitle(title).setMessage(R.string.write_place_name).setView(input)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override/* w w  w .  ja v  a 2s. co m*/
                public void onClick(DialogInterface dialog, int which) {
                    String newName = input.getText().toString();
                    renamePlace(placeName, newName);
                    dialog.dismiss();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    dialog.show();
}

From source file:com.romanenco.gitt.BrowserActivity.java

/**
 * When pull from origin there are several case.
 * 1. We are in TAG (detached head): will inform user to
 * checkout a branch first./*ww  w .  j  a v a  2s.  c  o m*/
 * 2. Authentication required: ask for password (no passwd save).
 * 3. Anonymous user: just poll.
 */
private void pullFromOrigin() {
    if (current.getUserName() == null) {
        //no authentication required
        current.setState(Repo.State.Busy);
        DAO dao = new DAO(BrowserActivity.this);
        dao.open(true);
        dao.update(current);
        dao.close();
        Intent pull = new Intent(this, GitService.class);
        pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
        pull.putExtra(GitService.REPO, current);
        startService(pull);
        Intent main = new Intent(this, MainActivity.class);
        main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(main);
    } else {
        String req = getString(R.string.passwd_request, current.getUserName());
        final EditText passwd = new EditText(this);
        passwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        AlertDialog dlg = new AlertDialog.Builder(this).setMessage(req)
                .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        String password = passwd.getText().toString();
                        if (TextUtils.isEmpty(password)) {
                            pullFromOrigin();
                        } else {
                            current.setState(Repo.State.Busy);
                            DAO dao = new DAO(BrowserActivity.this);
                            dao.open(true);
                            dao.update(current);
                            dao.close();
                            Intent pull = new Intent(BrowserActivity.this, GitService.class);
                            pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
                            pull.putExtra(GitService.REPO, current);
                            pull.putExtra(GitService.AUTH_PASSWD, password);
                            startService(pull);
                            Intent main = new Intent(BrowserActivity.this, MainActivity.class);
                            main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(main);
                        }
                    }
                }).setNegativeButton(getString(android.R.string.cancel), null).create();
        dlg.setCanceledOnTouchOutside(false);
        dlg.setView(passwd);
        dlg.show();
    }

}

From source file:adventure_fragments.Biking.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);//from ww  w. j  av a 2s  .  c  o m
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            }

            else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemBiking(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsBiking();
                adapt = new CustomAdapter(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_bike);
                listItem.setAdapter(adapt);
                nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_bike);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.show();
}

From source file:adventure_fragments.Camping.java

public void AddItemNow() {
    final EditText input;

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add item to list");
    input = new EditText(getActivity());
    int maxLength = 20;
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });

    builder.setView(input);//  w w  w.  ja va  2 s . c  om
    builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item_name = input.getText().toString();

            if (item_name.equals("")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals(" ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("  ")) {
                Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show();
            } else if (item_name.equals("This app sucks")) {
                Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show();
            } else {

                ItemClass itemClass = new ItemClass(item_name, 0);
                db.addItemCamping(itemClass);
                adapt.add(itemClass);
                adapt.notifyDataSetChanged();
                list = db.getAllItemsCamping();
                adapt = new CustomAdapter1(getActivity(), R.layout.item_layout, list);
                listItem = (ListView) getActivity().findViewById(R.id.listview_camp);
                listItem.setAdapter(adapt);
                count = listItem.getCount();
                if (count > 0) {
                    nothingtext.setVisibility(View.GONE);
                } else if (count == 0) {
                    nothingtext.setVisibility(View.VISIBLE);
                }

            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            list = db.getAllItemsCamping();
            adapt = new CustomAdapter1(getActivity(), R.layout.item_layout, list);
            listItem = (ListView) getActivity().findViewById(R.id.listview_camp);
            listItem.setAdapter(adapt);

            dialog.dismiss();
        }
    });

    builder.show();
}