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:edu.umich.oasis.testapp.PerfActivity.java

public static int getClampedSandboxCount(EditText text) {
    int count = Integer.parseInt(text.getText().toString());
    return Math.max(0, Math.min(count, OASISConstants.NUM_SANDBOXES));
}

From source file:ee.ioc.phon.android.speak.Utils.java

public static AlertDialog getTextEntryDialog(Context context, String title, String initialText,
        final ExecutableString ex) {
    final View textEntryView = LayoutInflater.from(context).inflate(R.layout.alert_dialog_text_entry, null);
    final EditText et = (EditText) textEntryView.findViewById(R.id.url_edit);
    et.setText(initialText);//from   w  w w. j av a  2  s  .com
    return new AlertDialog.Builder(context).setTitle(title).setView(textEntryView)
            .setPositiveButton(R.string.buttonOk, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    ex.execute(et.getText().toString());
                }
            }).setNegativeButton(R.string.buttonCancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            }).create();
}

From source file:nya.miku.wishmaster.http.cloudflare.CloudflareUIHandler.java

/**
 *  ?-?  Cloudflare./*  w w  w.  j  a  v a  2 s.  c  om*/
 *    
 * @param e ? {@link CloudflareException}
 * @param chan  
 * @param activity ?,    ?  ( ?  ? ),
 *   ?   ? WebView ? Anti DDOS  ? javascript.
 * ???  ?  UI  ({@link Activity#runOnUiThread(Runnable)})
 * @param cfTask ?? 
 * @param callback ? {@link Callback}
 */
static void handleCloudflare(final CloudflareException e, final HttpChanModule chan, final Activity activity,
        final CancellableTask cfTask, final InteractiveException.Callback callback) {
    if (cfTask.isCancelled())
        return;

    if (!e.isRecaptcha()) { // ? anti DDOS 
        if (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) {
            //?  ?   ??  ,   ?  ? ?
            // ?, ?      ChanModule,    
            //  ?  ?  () cloudflare  ? ?
            //  ?  ? ? ?   ? CloudflareChecker
            while (!CloudflareChecker.getInstance().isAvaibleAntiDDOS())
                Thread.yield();
            if (!cfTask.isCancelled())
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onSuccess();
                    }
                });
            return;
        }

        Cookie cfCookie = CloudflareChecker.getInstance().checkAntiDDOS(e, chan.getHttpClient(), cfTask,
                activity);
        if (cfCookie != null) {
            chan.saveCookie(cfCookie);
            if (!cfTask.isCancelled()) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onSuccess();
                    }
                });
            }
        } else if (!cfTask.isCancelled()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    callback.onError(activity.getString(R.string.error_cloudflare_antiddos));
                }
            });
        }
    } else { //  ? 
        final Recaptcha recaptcha;
        try {
            recaptcha = CloudflareChecker.getInstance().getRecaptcha(e, chan.getHttpClient(), cfTask);
        } catch (RecaptchaException recaptchaException) {
            if (!cfTask.isCancelled())
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onError(activity.getString(R.string.error_cloudflare_get_captcha));
                    }
                });
            return;
        }

        if (!cfTask.isCancelled())
            activity.runOnUiThread(new Runnable() {
                @SuppressLint("InflateParams")
                @Override
                public void run() {
                    Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
                            ? new ContextThemeWrapper(activity, R.style.Neutron_Medium)
                            : activity;
                    View view = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_cloudflare_captcha,
                            null);
                    ImageView captchaView = (ImageView) view.findViewById(R.id.dialog_captcha_view);
                    final EditText captchaField = (EditText) view.findViewById(R.id.dialog_captcha_field);
                    captchaView.setImageBitmap(recaptcha.bitmap);

                    DialogInterface.OnClickListener process = new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (cfTask.isCancelled())
                                return;
                            PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() {
                                @Override
                                public void run() {
                                    String answer = captchaField.getText().toString();
                                    Cookie cfCookie = CloudflareChecker.getInstance().checkRecaptcha(e,
                                            (ExtendedHttpClient) chan.getHttpClient(), cfTask,
                                            recaptcha.challenge, answer);
                                    if (cfCookie != null) {
                                        chan.saveCookie(cfCookie);
                                        if (!cfTask.isCancelled()) {
                                            activity.runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    callback.onSuccess();
                                                }
                                            });
                                        }
                                    } else {
                                        //   (?,  ,    )
                                        handleCloudflare(e, chan, activity, cfTask, callback);
                                    }
                                }
                            }).start();
                        }
                    };

                    DialogInterface.OnCancelListener onCancel = new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            callback.onError(activity.getString(R.string.error_cloudflare_cancelled));
                        }
                    };

                    if (cfTask.isCancelled())
                        return;

                    final AlertDialog recaptchaDialog = new AlertDialog.Builder(dialogContext).setView(view)
                            .setPositiveButton(R.string.dialog_cloudflare_captcha_check, process)
                            .setOnCancelListener(onCancel).create();
                    recaptchaDialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                    recaptchaDialog.setCanceledOnTouchOutside(false);
                    recaptchaDialog.show();

                    captchaView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            recaptchaDialog.dismiss();
                            if (cfTask.isCancelled())
                                return;
                            PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() {
                                @Override
                                public void run() {
                                    handleCloudflare(e, chan, activity, cfTask, callback);
                                }
                            }).start();
                        }
                    });
                }
            });
    }
}

From source file:MainActivity.java

public void onClickSwitchActivity(View view) {
    EditText editText = (EditText) findViewById(R.id.editTextData);
    String text = editText.getText().toString();
    Intent intent = new Intent(this, SecondActivity.class);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    startActivityForResult(intent, 1);//ww w.j  a  v  a  2s  .  c  o  m
}

From source file:MainActivity.java

public void onClickSwitchActivity(View view) {
    EditText editText = (EditText) findViewById(R.id.editTextData);
    String text = editText.getText().toString();
    Intent intent = new Intent(this, SecondActivity.class);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    startActivity(intent);//  w ww.j ava 2 s.c o m
}

From source file:cn.apputest.ctria.section2.Dialog_DriverLicenseCard.java

void getDriverLicense(final EditText carnum) {

    DriverLicenseNumber = carnum.getText().toString();

    DriverLicenseCardDataEntity driverlicense = new DriverLicenseCardDataEntity();
    String cariD = carnum.getText().toString();
    driverlicense = mgr.queryDriverLicenseCard(cariD);
    if (StringUtils.isNotBlank(driverlicense.getDriverInfo())) {
        Information.setText(driverlicense.getDriverInfo());
    } else {/*from   www  .j  a va 2  s. co m*/
        Information.setText("??");
    }
}

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

public static void addContact(final Context context) {

    final EditText input = new EditText(context); // Set an EditText view to get user input
    input.setSingleLine(true);/*www  .  j  a v  a2  s. c om*/
    input.setHint(R.string.contact_email_address);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);

    final AlertDialog addContactDialog = new AlertDialog.Builder(context)
            .setTitle(context.getResources().getString(R.string.add_contact)).setView(input)
            .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create();

    addContactDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

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

                            String email = value.toString();

                            try {
                                ServerApi.allowPeople(context, email);
                                Toast.makeText(context, R.string.contact_added, Toast.LENGTH_SHORT).show();
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            addContactDialog.dismiss();
                        }
                    });
        }
    });

    addContactDialog.show();
}

From source file:com.example.run_tracker.LoginFragment.java

private boolean isEmpty(EditText etText) {
    return etText.getText().toString().trim().length() == 0;
}

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

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    ticketid = getIntent().getStringExtra("ticketid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addticketreply);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/* w  w w.  jav a2 s.  c om*/
            if (TicketID == 0) {
                Toast.makeText(AddTicketReply.this,
                        "Ticket Reply Failed. Please try again later or email request@dedipower.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(AddTicketReply.this, "Reply added! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitReply = new Thread() {
        public void run() {
            try {
                TicketID = API.ReplyToTicket(ticketid, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button AddReplyButton = (Button) findViewById(R.id.AddReplyButton);
    AddReplyButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Message = MessageET.getText().toString();

            submitReply.start();
        }
    });
}

From source file:net.networksaremadeofstring.pulsant.portal.AddTicketReply.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    ticketid = getIntent().getStringExtra("ticketid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addticketreply);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from ww w. j a v  a  2 s  . c o  m*/
            if (TicketID == 0) {
                Toast.makeText(AddTicketReply.this,
                        "Ticket Reply Failed. Please try again later or email request@Pulsant.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(AddTicketReply.this, "Reply added! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitReply = new Thread() {
        public void run() {
            try {
                TicketID = API.ReplyToTicket(ticketid, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button AddReplyButton = (Button) findViewById(R.id.AddReplyButton);
    AddReplyButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Message = MessageET.getText().toString();

            submitReply.start();
        }
    });
}