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:com.grupohqh.carservices.operator.ReadTagActivity.java

private boolean validate() {
    EditText editText = null;
    switch (key) {
    case "tag":
        editText = etTag;//from  w w  w  .  j a va2 s .  c  o  m
        break;
    case "license_plate":
        editText = etLicensePlate;
        break;
    case "serial_number":
        editText = etSerialNumber;
        break;
    default:
        return false;
    }
    if (editText.getText().toString().trim().equals("")) {
        Toast.makeText(getBaseContext(), "Favor de escanear TAG", Toast.LENGTH_LONG).show();
        return false;
    }
    return true;
}

From source file:edu.asu.msse.dssoni.moviedescrpitionapp.AddActivity.java

public void addNewItem(View v) throws JSONException {
    EditText titleText = (EditText) findViewById(R.id.editText);
    EditText yearText = (EditText) findViewById(R.id.editText2);
    EditText ratingText = (EditText) findViewById(R.id.editText3);
    EditText releasedText = (EditText) findViewById(R.id.editText4);
    EditText actorsText = (EditText) findViewById(R.id.editText5);
    EditText runText = (EditText) findViewById(R.id.editText7);
    EditText plotText = (EditText) findViewById(R.id.editText8);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);

    title = titleText.getText().toString();
    year = yearText.getText().toString();
    rated = ratingText.getText().toString();
    released = releasedText.getText().toString();
    actors = actorsText.getText().toString();
    runtime = runText.getText().toString();
    plot = plotText.getText().toString();
    genre = spinner.getSelectedItem().toString();

    JSONObject jo = new JSONObject();
    jo.put("Title", title);
    jo.put("Year", year);
    jo.put("Rated", rated);
    jo.put("Released", released);
    jo.put("Runtime", runtime);
    jo.put("Genre", genre);
    jo.put("Actors", actors);
    jo.put("Plot", plot);

    String jsonString = jo.toString();
    Intent intent = new Intent();
    intent.putExtra("newJsonString", jsonString);
    setResult(2, intent);/*from  www  .j a  v a2  s .  c o m*/
    finish();
}

From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java

private Dialog onCreatePasswdDialog() {
    final AlertDialog.Builder ab = new AlertDialog.Builder(this);
    ab.setPositiveButton(R.string.ok, new OnClickListener() {
        @Override//from   w  w  w. java  2s. c  o m
        public void onClick(DialogInterface dialog, int which) {
            if (dialog instanceof AlertDialog) {
                final AlertDialog dlg = (AlertDialog) dialog;
                final EditText passwd = (EditText) dlg.findViewById(R.id.dialog_text);
                if (passwd == null) {
                    return;
                }
                mPasswd = passwd.getText().toString();
                updateMessage(R.string.login_google, null);
                new Thread(new Runnable() {
                    public void run() {
                        login();
                    }
                }).start();
            }
        }
    });
    ab.setNegativeButton(R.string.cancel, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
    });
    ab.setTitle("Password for " + mAccount.name);
    final LayoutInflater inflator = getLayoutInflater();
    ab.setView(inflator.inflate(R.layout.passwd, null));
    return ab.create();
}

From source file:com.yozio.demo.implementations.share.ShareButtonsActivity.java

public void showShareCommentDialog(Context context, final DialogFlowController controller) {

    final EditText text = new EditText(context);
    text.setMinLines(5);//  w  w  w . j  a  v a 2  s .  c  om
    text.setGravity(Gravity.TOP);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Share");
    builder.setMessage("Enter a comment (Optional)");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            controller.onContinue(text.getText().toString());
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            controller.onCancel();
        }
    });

    AlertDialog dialog = builder.create();
    dialog.setView(text);
    dialog.show();
}

From source file:com.socialapp.eventmanager.LoginActivity.java

public void login_for_test(View view) {
    final EditText emailView = (EditText) findViewById(R.id.email);
    EditText pwView = (EditText) findViewById(R.id.password);
    final Context currContext = this;

    String email = emailView.getText().toString();
    String password = pwView.getText().toString();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString("email", emailView.getText().toString());
    editor.commit();/*from ww  w  .  j av a2 s  .c  o m*/

    Intent intent = new Intent(currContext, MainActivity.class);
    startActivity(intent);
}

From source file:fm.libre.droid.LibreDroid.java

public void login() {
    final EditText usernameEntry = (EditText) findViewById(R.id.usernameEntry);
    final EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry);
    username = usernameEntry.getText().toString();
    password = passwordEntry.getText().toString();
    boolean loggedIn = libreServiceConn.service.login(username, password);
    if (loggedIn) {
        nextPage();/*from w w  w  . ja  v  a 2  s  . c  o  m*/
    }
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

public boolean isAnyFieldFilledOut() {
    int childCount = mFields.getChildCount();
    for (int i = 0; i < childCount; i++) {
        EditText editorView = (EditText) mFields.getChildAt(i);
        if (!TextUtils.isEmpty(editorView.getText())) {
            return true;
        }//from   ww w  . j av a2  s  . c o  m
    }
    return false;
}

From source file:com.notifry.android.SourceEditor.java

/**
 * Save this source./*from  w w w  . j  av a  2s  . c om*/
 */
public void save(View view) {
    // User clicked save button.
    // Prepare the new local object.
    this.source = null;
    NotifrySource source = this.getSource();

    EditText title = (EditText) findViewById(R.id.detail_title);
    source.setTitle(title.getText().toString());

    CheckBox serverEnable = (CheckBox) findViewById(R.id.detail_serverenable);
    source.setServerEnabled(serverEnable.isChecked());
    CheckBox localEnable = (CheckBox) findViewById(R.id.detail_localenable);
    source.setLocalEnabled(localEnable.isChecked());

    // Now, send the updates to the server. On success, save the changes
    // locally.
    BackendRequest request = new BackendRequest("/sources/edit");
    request.add("id", source.getServerId().toString());
    request.add("title", source.getTitle());
    if (source.getServerEnabled()) {
        request.add("enabled", "on");
    }

    request.addMeta("source", source);
    request.addMeta("operation", "save");

    request.setHandler(handler);

    request.startInThread(this, getString(R.string.source_saving_to_server), source.getAccountName());
}

From source file:org.service.ApiRest.java

/**
 * Envia la imagen codificada al servidor
 *
 * @param String encodedImage Imagen codificada con Base64
 * @throws IOException//from w  w w . j av  a  2s  . c  o  m
 * @throws ClientProtocolException
 * @throws JSONException
 *
 */
public Boolean uploadPhoto(String encodedImage, EditText name, EditText nameFloor, EditText numberFloor)
        throws ClientProtocolException, IOException, JSONException {
    HttpClient httpclient = new DefaultHttpClient();
    //url y tipo de contenido
    HttpPost httppost = new HttpPost(HTTP_EVENT);
    httppost.addHeader("Content-Type", "application/json");
    //forma el JSON y tipo de contenido
    JSONObject jsonObject = new JSONObject();

    UUID uuid = UUID.randomUUID();
    String randomUUIDString = uuid.toString();
    jsonObject.put("idEdifice", randomUUIDString);
    jsonObject.put("NameEdifice", name.getText().toString());
    jsonObject.put("photo", encodedImage);
    jsonObject.put("idFloor", UUID.randomUUID().toString());
    jsonObject.put("NameFloor", nameFloor.getText().toString());
    jsonObject.put("NumberFloor", numberFloor.getText().toString());

    //
    StringEntity stringEntity = new StringEntity(jsonObject.toString());
    // stringEntity.setContentType((Header) new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    httppost.setEntity(stringEntity);
    //ejecuta
    HttpResponse response = httpclient.execute(httppost);
    //obtiene la respuesta y transorma a objeto JSON 
    String jsonResult = inputStreamToString(response.getEntity().getContent()).toString();
    JSONObject object = new JSONObject(jsonResult);
    if (object.getString("status").equals("200")) {
        return true;
    }
    return false;
}

From source file:alexander.martinz.libs.materialpreferences.MaterialEditTextPreference.java

protected AlertDialog createAlertDialog() {
    final Context context = getContext();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(getTitle());/*from w w w .  jav  a  2s. co  m*/

    // create the wrapper layout to apply margins to the edit text
    final LinearLayout wrapper = new LinearLayout(context);
    wrapper.setOrientation(LinearLayout.VERTICAL);
    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final int margin = (int) convertDpToPixels(10);
    layoutParams.setMargins(margin, 0, margin, 0);

    // create the EditText and add it to the wrapper layout
    final EditText editText = new EditText(context);
    editText.setText(mValue);
    wrapper.addView(editText, layoutParams);

    // set our wrapper as view
    builder.setView(wrapper);

    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String value = editText.getText().toString();
            if (TextUtils.equals(value, mValue)) {
                // the value did not change, so lets end here
                return;
            }

            mValue = value;
            final MaterialEditTextPreference preference = MaterialEditTextPreference.this;

            if (mListener != null) {
                if (mListener.onPreferenceChanged(preference, mValue)) {
                    setText(mValue);
                }
            } else {
                setText(mValue);
            }
        }
    });

    return builder.create();
}