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:company.test.Test.java

@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();

    switch (id) {
    case R.id.add_item:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Add a task");
        builder.setMessage("What do you want to do?");
        final EditText inputField = new EditText(this);
        builder.setView(inputField);/*from   www . j  av  a2  s. c  o  m*/
        builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                String task = inputField.getText().toString();
                Log.d("MainActivity", task);

                SQLiteDatabase db = helper.getWritableDatabase();
                ContentValues values = new ContentValues();

                values.clear();
                values.put(ItemContract.Columns.ITEM, task);

                db.insertWithOnConflict(ItemContract.TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);

                activity.updateUI();
            }
        });

        builder.setNegativeButton("Cancel", null);

        builder.create().show();
        return true;
    case R.id.action_settings:
        Log.d("MainActivity", "Settings");
        return true;
    default:
        return false;
    }
}

From source file:com.attentec.Login.java

@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);//from  ww w  . j  a va2s.  co m
    makeButton();

    Button scanButton = (Button) findViewById(R.id.scan_button);
    scanButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(final View v) {
            //save username so we don't lose it while reading qr code
            EditText usernameEditText = (EditText) findViewById(R.id.txt_username);
            saveUserName(usernameEditText.getText().toString());

            //read qr code
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            try {
                startActivityForResult(intent, REQUEST_PHONE_KEY_SCANNER_REQUEST_CODE);
            } catch (ActivityNotFoundException e) {
                showFailedScan();
            }
        }
    });

    if (!readKey().equals("")) {
        login(readKey(), readUserName());
    }
}

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

/**
 * Get the value of an edit text a safe way
 * @param txt The edit text to get value of
 * @return the Text value of the edit text
 *///from w  ww  .  j a v  a 2 s  . c om
private String getEditTextValue(EditText txt) {
    if (txt == null) {
        return "";
    }
    String res = txt.getText().toString();
    if (TextUtils.isEmpty(res)) {
        return "";
    }
    return res;
}

From source file:at.florian_lentsch.expirysync.AddProductActivity.java

/**
 * Creates an {@link Article} from the data entered by the user
 * //from  w  w w .j av  a 2  s.c o m
 * @return the requested {@link Article}
 */
private Article createArticleFromFormData() {
    EditText nameField = ((EditText) findViewById(R.id.product_name_field));

    Article article = new Article();

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

    return article;
}

From source file:gr.rambou.secheader.MainActivity.java

public void Button_Clicked(View v) {
    //find EditText View
    EditText txt_website = (EditText) findViewById(R.id.txt_websites);

    //Split string with comma and pass it into a string array
    String[] websites = txt_website.getText().toString().split(",");

    // Instantiate the RequestQueue.
    queue = Volley.newRequestQueue(this);

    //Set requests number
    requests = websites.length;//from w ww  . j  a v a  2s .co  m

    //Disable Buttons functionality
    (findViewById(R.id.button_scan)).setEnabled(false);
    (findViewById(R.id.checkbox_save)).setEnabled(false);

    //Initialize progressBar
    ((ProgressBar) findViewById(R.id.progressBar)).setMax(requests);
    ((ProgressBar) findViewById(R.id.progressBar)).setProgress(0);

    //Start getting each website headers
    for (String url : websites) {
        //fix url
        if (!url.toLowerCase().contains("http://") && !url.toLowerCase().contains("https://"))
            url = "http://" + url.trim();
        //get headers and analyze them
        getHeader(url);
    }

}

From source file:com.memetro.android.MainActivity.java

public void showRecoverPassDialog(final Context context) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.dialog_recover);
    mDialog.setCancelable(true);/*from  ww  w. ja v  a  2s  . c om*/

    final EditText emailText = (EditText) mDialog.findViewById(R.id.email);
    Button sendButton = (Button) mDialog.findViewById(R.id.send);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            RecoverPassUtils.recoverPass(context, emailText.getText().toString(), new OAuthHandler() {
                public void onStart() {
                    pdialog.show();
                }

                public void onSuccess() {
                    mDialog.dismiss();
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ok));
                }

                public void onFailure() {
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ko));
                }

                public void onFinish() {
                    pdialog.dismiss();
                }
            });
        }
    });

    mDialog.show();
}

From source file:com.dedipower.portal.android.Launcher.java

/** Called when the activity is first created. */
@Override//  ww  w.j a  va2s  .co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.launcher);

    dialog = new ProgressDialog(this);
    dialog.setMessage("Logging in.....");

    //Get our settings
    settings = getSharedPreferences("Dedipower", 0);
    ManageSettings();

    handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            //Apparantly stopping threads is no longer supported
            //peformLogin.stop();

            if (APIResponse == "true") {
                //Tell the user
                Toast.makeText(Launcher.this, "Login Successful", Toast.LENGTH_SHORT).show();

                //Check the "remember details checkbox"
                CheckBox Remember = (CheckBox) findViewById(R.id.RememberDetailsCheckBox);

                SharedPreferences.Editor editor = settings.edit();
                if (Remember.isChecked() == true) {
                    editor.putString("AcctCode", AcctCode);
                    editor.putString("Email", Email);
                    editor.putString("Password", Password);
                    editor.putBoolean("Remember", true);
                    editor.commit();
                } else {
                    editor.putString("AcctCode", "");
                    editor.putString("Email", "");
                    editor.putString("Password", "");
                    editor.putBoolean("Remember", false);
                    editor.commit();
                }

                //Do extent stuff
                Intent LauncherIntent = new Intent(Launcher.this, PortalLanding.class);
                LauncherIntent.putExtra("sessionid", API.SessionID);
                Launcher.this.startActivity(LauncherIntent);
                finish();
            } else {
                Toast.makeText(Launcher.this, "Login Failed: " + APIResponse, Toast.LENGTH_SHORT).show();
            }
        }
    };

    Button LoginButton = (Button) findViewById(R.id.LoginButton);
    LoginButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText AcctCodeEditText = (EditText) findViewById(R.id.AcctCodeInput);
            EditText EmailEditText = (EditText) findViewById(R.id.EmailInput);
            EditText PasswordEditText = (EditText) findViewById(R.id.PasswordInput);
            AcctCode = AcctCodeEditText.getText().toString();
            Email = EmailEditText.getText().toString();
            Password = PasswordEditText.getText().toString();

            Credentials.add(new BasicNameValuePair("account", AcctCode));
            Credentials.add(new BasicNameValuePair("username", Email));
            Credentials.add(new BasicNameValuePair("password", Password));
            CreateThread();
            peformLogin.start();

            /*String APIResponse = API.Login(Credentials);
            if(APIResponse == "true")
            {
              //Tell the user
              Toast.makeText(Launcher.this, "Login Successful", Toast.LENGTH_SHORT).show();
                      
              //Check the "remember details checkbox"
              CheckBox Remember = (CheckBox) findViewById(R.id.RememberDetailsCheckBox);
                      
              SharedPreferences.Editor editor = settings.edit();
              if(Remember.isChecked() == true)
              {
                editor.putString("AcctCode", AcctCodeEditText.getText().toString());
                editor.putString("Email", EmailEditText.getText().toString());
                editor.putString("Password", PasswordEditText.getText().toString());
                editor.putBoolean("Remember", true);
                editor.commit();
              }
              else
              {
                editor.putString("AcctCode", "");
                editor.putString("Email", "");
                editor.putString("Password", "");
                editor.putBoolean("Remember", false);
                editor.commit();
              }
                      
              //Do extent stuff
              Intent LauncherIntent = new Intent(Launcher.this, PortalLanding.class);
              LauncherIntent.putExtra("sessionid", API.SessionID);
              Launcher.this.startActivity(LauncherIntent);
              finish();
            }
            else
            {
              Toast.makeText(Launcher.this, "Login Failed: " + APIResponse, Toast.LENGTH_SHORT).show();
            }*/
        }
    });
}

From source file:com.example.chromecat.ChromeCatActivity.java

/**
  * Initializes all buttons by adding user controls and listeners.
  *///from  w ww .ja v  a  2s .  co  m
public void initButtons() {
    msgButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText input = (EditText) findViewById(R.id.msg_text);
            String msg_text = input.getText().toString();
            sendMessage("message", msg_text);
        }
    });

    urlButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText input = (EditText) findViewById(R.id.url_text);
            String msg_text = input.getText().toString();
            sendMessage("url", msg_text);
        }
    });
}

From source file:com.bringcommunications.etherpay.SendActivity.java

public void do_pay(View view) {
    if (send_is_done)
        return;//from   w w  w .jav a 2  s.c  om
    //validate size... we check for sufficient balance later...
    EditText size_view = (EditText) findViewById(R.id.size);
    String user_size_str = size_view.getText().toString();
    float user_size = Float.valueOf(user_size_str);
    eth_size = (denomination == Denomination.ETH) ? user_size : user_size / 1000;
    if (eth_size == 0) {
        Toast.makeText(context, "Cannot send zero ETH", Toast.LENGTH_LONG).show();
        return;
    }
    if (show_gas) {
        TextView gas_view = (TextView) findViewById(R.id.gas);
        String gas_limit_str = gas_view.getText().toString().trim();
        try {
            gas_limit = Long.valueOf(gas_limit_str);
        } catch (NumberFormatException e) {
            Toast.makeText(context, "Unable to parse Gas limit: " + gas_limit_str, Toast.LENGTH_LONG).show();
            return;
        }
    }
    if (gas_limit < Util.DEFAULT_GAS_LIMIT) {
        Toast.makeText(context, "Gas limit is too low -- transaction might not succeed!", Toast.LENGTH_LONG)
                .show();
        return;
    }
    //ensure sufficient funds
    long gas_price = preferences.getLong("gas_price", Util.DEFAULT_GAS_PRICE);
    float max_gas_eth = (gas_limit * gas_price) / WEI_PER_ETH;
    if (eth_size + max_gas_eth > eth_balance) {
        String balance_str = String.format("%1.06f", eth_balance);
        String size_str = String.format("%1.06f", eth_size);
        String gas_str = String.format("%1.08f", max_gas_eth);
        String msg = "Balance (" + balance_str + ") is not sufficient to cover " + size_str + " ETH, plus "
                + gas_str + " GAS";
        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        return;
    }
    //validate to_addr
    if (!to_addr.startsWith("0x") || to_addr.length() != 42) {
        Toast.makeText(context, "Recipient address is not valid; length is " + to_addr.length(),
                Toast.LENGTH_LONG).show();
        return;
    }
    if (to_addr.equals(acct_addr)) {
        Toast.makeText(context, "Recipient cannot be the same as your account address", Toast.LENGTH_LONG)
                .show();
        return;
    }
    EditText data_view = (EditText) findViewById(R.id.data);
    data = data_view.getText().toString();
    long size_wei = (long) (eth_size * WEI_PER_ETH);
    Payment_Processor.send(this, context, "", to_addr, size_wei, gas_limit, data.getBytes(), false);
    send_is_done = true;
    Button pay_view = (Button) findViewById(R.id.pay_button);
    pay_view.setClickable(false);
}

From source file:com.crossword.activity.FeedbackActivity.java

public void postMessage() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(Crossword.MAIL_URL);
    try {/*from ww w. j  a  va 2  s .  c o  m*/
        EditText feedMessage = (EditText) findViewById(R.id.feed_message);

        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("from",
                android.os.Build.MODEL + " (" + android.os.Build.VERSION.RELEASE + ")"));
        nameValuePairs.add(new BasicNameValuePair("message", feedMessage.getText().toString()));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);
        if (response.getStatusLine().getStatusCode() == 200) {
            runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(FeedbackActivity.this, R.string.feedback_send_success, Toast.LENGTH_SHORT)
                            .show();
                }
            });
            finish();
            return;
        }

        String line;
        StringBuilder total = new StringBuilder();
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        while ((line = rd.readLine()) != null) {
            total.append(line);
        }
        error = Html.fromHtml(total.toString()).toString();
    } catch (ClientProtocolException e) {
        error = getResources().getString(R.string.exception_network);
        e.printStackTrace();
    } catch (IOException e) {
        error = getResources().getString(R.string.exception_network);
        e.printStackTrace();
    }
}