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:at.florian_lentsch.expirysync.EditProductActivity.java

/**
 * Updates the entry that is being edited with data entered by the user
 *//*w ww .j a v  a  2  s .  c o  m*/
private void updateCurrentEntryFromFormData() {
    final DatabaseManager dbManager = DatabaseManager.getInstance();

    EditText nameField = ((EditText) findViewById(R.id.product_name_field));
    EditText amountField = ((EditText) findViewById(R.id.amount_field));
    String amountStr = amountField.getText().toString();

    this.curEntry.article.barcode = ((EditText) findViewById(R.id.barcode_field)).getText().toString();
    this.curEntry.article.name = nameField.getText().toString();

    this.curEntry.article = dbManager.updateOrAddArticle(this.curEntry.article);

    if (amountStr.trim().equals("")) {
        amountStr = DEFAULT_AMOUNT;
    }
    this.curEntry.amount = Integer.parseInt(amountStr);
    this.curEntry.description = ((EditText) findViewById(R.id.product_description_field)).getText().toString();

    DatePicker datePicker = (DatePicker) findViewById(R.id.expiration_date_field);
    this.curEntry.expiration_date = (new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(),
            datePicker.getDayOfMonth())).getTime();
}

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

public static void addPlace(final Context context, final LatLng latLng, final int radius) {
    final EditText input = new EditText(context); // Set an EditText view to get user input
    input.setSingleLine(true);//from  w w  w.j a  va  2 s. co m
    final AlertDialog addPlaceDialog = new AlertDialog.Builder(context)
            .setTitle(context.getResources().getString(R.string.write_place_name)).setView(input)
            .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create();

    addPlaceDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            ((FragmentActivity) context).findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE); // todo maybe re enabled this... it will however also fire on empty input
        }
    });
    addPlaceDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

            addPlaceDialog.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;
                            }

                            try {
                                ServerApi.addPlace(context, value.toString(), latLng, radius);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            addPlaceDialog.dismiss();
                        }
                    });
        }
    });

    addPlaceDialog.show();
}

From source file:edu.asu.bsse.vtanders.finalproject.MainActivity.java

License:asdf

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_config) {
        AlertDialog.Builder connInfoDialogBuilder = new AlertDialog.Builder(this);
        connInfoDialogBuilder.setTitle("Server Information");
        final View view = getLayoutInflater().inflate(R.layout.server_config, null);
        connInfoDialogBuilder.setView(view);
        final AlertDialog connInfoDialog = connInfoDialogBuilder.create();
        connInfoDialog.show();//  w  w  w. j a v a2s.  co  m
        Button apply = (Button) view.findViewById(R.id.apply_settings_button);
        apply.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText hostET = (EditText) view.findViewById(R.id.host_content);
                String host = hostET.getText().toString();

                EditText portET = (EditText) view.findViewById(R.id.port_content);
                int port = Integer.valueOf(portET.getText().toString());

                EditText nickET = (EditText) view.findViewById(R.id.nickname_content);
                String nick = nickET.getText().toString();

                Log.d("ASDF", host + " " + port + " " + nick);

                new SetupConnectionTask(host, port, nick).execute();
                connInfoDialog.dismiss();
            }
        });

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:net.exclaimindustries.geohashdroid.wiki.WikiMessageEditor.java

private void resetSubmitButton() {
    // Make sure the submit button is disabled if there's no text ready.
    // That's all.  We can send things anonymously.
    Button submitButton = (Button) findViewById(R.id.wikieditbutton);
    EditText message = (EditText) findViewById(R.id.wikiedittext);

    if (message == null || message.getText().toString().length() <= 0) {
        submitButton.setEnabled(false);//from   ww  w.j  ava  2  s  .c o m
    } else {
        submitButton.setEnabled(true);
    }
}

From source file:org.projecthdata.weight.WeightTrackerActivity.java

public void onSave(View v) {
    try {//from ww w  .  j  a v a 2  s. c  o m
        WeightReading reading = new WeightReading();
        EditText weightEditText = (EditText) findViewById(R.id.weight_edit_text);
        Double entry = Double.parseDouble(weightEditText.getText().toString());
        reading.setResultValue(entry);
        getDatabaseHelper().getWeightDao().create(reading);
        // go back to displaying the weight list
        getSupportFragmentManager().popBackStack();

        // hide the soft keyboard
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(weightEditText.getWindowToken(), 0);

    } catch (SQLException e) {
        e.printStackTrace();
    }

}

From source file:com.example.hbranciforte.trafficclient.DataTraffic.java

private JSONObject getCarInfo() {
    JSONObject car = new JSONObject();
    EditText licenseLetters = (EditText) findViewById(R.id.license_letters);
    EditText licenseNumbers = (EditText) findViewById(R.id.license_numbers);
    try {/* w ww .j av  a  2s .  co m*/
        car.put("license_plate",
                licenseLetters.getText().toString().toUpperCase().concat(licenseNumbers.getText().toString()));
    } catch (JSONException e) {
        Log.e("JSON error", e.getMessage());
    }
    return car;
}

From source file:com.google.maps.android.utils.demo.HeatmapsPlacesDemoActivity.java

/**
 * Takes the input from the user and generates the required heatmap.
 * Called when a search query is submitted
 *//*from   ww w. java  2 s .com*/
public void submit() {
    if ("YOUR_KEY_HERE".equals(API_KEY)) {
        Toast.makeText(this,
                "Please sign up for a Places API key and add it to HeatmapsPlacesDemoActivity.API_KEY",
                Toast.LENGTH_LONG).show();
        return;
    }
    EditText editText = (EditText) findViewById(R.id.input_text);
    String keyword = editText.getText().toString();
    if (mOverlays.contains(keyword)) {
        Toast.makeText(this, "This keyword has already been inputted :(", Toast.LENGTH_SHORT).show();
    } else if (mOverlaysRendered == MAX_CHECKBOXES) {
        Toast.makeText(this, "You can only input " + MAX_CHECKBOXES + " keywords. :(", Toast.LENGTH_SHORT)
                .show();
    } else if (keyword.length() != 0) {
        mOverlaysInput++;
        ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.VISIBLE);
        new MakeOverlayTask().execute(keyword);
        editText.setText("");

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    }
}

From source file:es.uniovi.imovil.fcrtrainer.BinaryExerciseFragment.java

private String answerFromUserInput() {
    EditText answerEditText = (EditText) rootView.findViewById(R.id.answer);
    String answer = answerEditText.getText().toString();

    // System.out.println("answer: " + answer);
    return answer;
}

From source file:com.csipsimple.wizards.impl.MondotalkCreate.java

private boolean checkEmptyText(EditText txt) {
    if (TextUtils.isEmpty(txt.getText().toString())) {
        txt.setError("Empty");
        return false;
    }//from   w w w  .j a v a  2s . co  m
    txt.setError(null);
    return true;
}

From source file:com.eyekabob.AddBand.java

public void submit(View v) {
    Spinner genreSpinner = (Spinner) findViewById(R.id.genreSpinner);
    EditText nameEditText = (EditText) findViewById(R.id.artistNameEditText);
    EditText urlEditText = (EditText) findViewById(R.id.urlEditText);
    EditText bioEditText = (EditText) findViewById(R.id.artistDescriptionEditText);

    String genre = (String) genreSpinner.getSelectedItem();
    String name = nameEditText.getText().toString();
    String url = urlEditText.getText().toString();
    String bio = bioEditText.getText().toString();

    if (getResources().getString(R.string.genre).equals(genre)) {
        // TODO: make better validation message.
        Toast.makeText(this, "Select a genre", Toast.LENGTH_LONG).show();
        return;//  w  w w .  java 2s  . co  m
    }

    if (name == null || "".equals(name.trim())) {
        Toast.makeText(this, "Enter artist name", Toast.LENGTH_LONG).show();
        return;
    }

    Map<String, String> params = new HashMap<String, String>();
    params.put("genre", genre);
    params.put("name", name);
    params.put("url", url);
    params.put("bio", bio);
    Uri uri = EyekabobHelper.WebService.getURI("artist", "addArtist", params);
    new AddArtistTask().execute(uri);
}