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:kr.co.cashqc.MainActivity.java

@Override
protected Dialog onCreateDialog(int i) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

    LayoutInflater inflater = MainActivity.this.getLayoutInflater();

    final View view = inflater.inflate(R.layout.dialog_custom_login, null);

    builder.setView(view);//  ww  w .  j a v a2 s  .c o  m
    builder.setPositiveButton("login", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            EditText passwordEditText = (EditText) view.findViewById(R.id.password);
            // EditText distanceEditText = (EditText)
            // view.findViewById(R.id.distance);

            if (passwordEditText.getText().toString().equals("1599")) {
                adminFlag = true;
                Toast.makeText(mContext, "?", Toast.LENGTH_SHORT).show();
                // try {
                // mDistance =
                // Integer.parseInt(distanceEditText.getText().toString());
                // } catch (NumberFormatException e) {
                // e.printStackTrace();
                // mDistance = 3;
                // }
                mManualTextView.setVisibility(View.VISIBLE);
            } else {
                adminFlag = false;
                mDistance = 3;
                // mManualTextView.setVisibility(View.GONE);
            }

        }
    });

    return builder.create();
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onClick(View v) {
    EditText cueInput = (EditText) findViewById(R.id.cue);
    EditText responseInput = (EditText) findViewById(R.id.response);
    Spinner posInput = (Spinner) findViewById(R.id.pos);
    EditText characterResponseInput = (EditText) findViewById(R.id.response_character);
    EditText characterCueInput = (EditText) findViewById(R.id.cue_character);
    final String cue = cueInput.getText().toString();
    final String response = responseInput.getText().toString();
    final String pos = posInput.getSelectedItem().toString();
    final String character_cue = characterCueInput.getText().toString();
    final String character_response = characterResponseInput.getText().toString();
    String pos_code = Utils.POS_MAP.get(pos);
    if (TextUtils.isEmpty(pos_code)) {
        pos_code = "NONE";
    }/*from   w ww .j a  v  a2 s.c  o  m*/
    final String final_pos_code = pos_code;

    if (Main.isNotLoggedIn(this)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, LoginActivity.class.getName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
        // navigation
        // back to this?
        LoginActivity.return_to = CreateItemActivity.class.getName();
        LoginActivity.params = new HashMap<String, String>();
        LoginActivity.params.put("list_id", list_id);
        LoginActivity.params.put("cue", cue);
        LoginActivity.params.put("response", response);
        LoginActivity.params.put("cue_language", cue_language);
        LoginActivity.params.put("response_language", response_language);
        LoginActivity.params.put("pos", pos);
        LoginActivity.params.put("character_cue", character_cue);
        LoginActivity.params.put("character_response", character_response);
        startActivity(intent);
    } else {
        // TODO cue and response languages need to be inferred from list we are
        // adding to ... Might want to fix those, i.e. not allow variation
        // on
        // search ...
        // TODO wondering whether there is some way to edit existing items
        // ...

        final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
        myOtherProgressDialog.setTitle("Please Wait ...");
        myOtherProgressDialog.setMessage("Creating Item ...");
        myOtherProgressDialog.setIndeterminate(true);
        myOtherProgressDialog.setCancelable(true);

        final Thread create_item = new Thread() {
            public void run() {
                // TODO make this interruptable .../*if
                // (!this.isInterrupted())*/
                CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue,
                        final_pos_code, response, response_language, character_response, list_id);

                myOtherProgressDialog.dismiss();

            }
        };
        myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                create_item.interrupt();
            }
        });
        OnCancelListener ocl = new OnCancelListener() {
            public void onCancel(DialogInterface arg0) {
                create_item.interrupt();
            }
        };
        myOtherProgressDialog.setOnCancelListener(ocl);
        myOtherProgressDialog.show();
        create_item.start();
    }
}

From source file:at.alladin.rmbt.android.loopmode.LoopModeStartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().setTitle(R.string.preferences_category_loop_mode);

    final View v = inflater.inflate(R.layout.loop_mode_start_dialog, container, false);

    final int maxDelay = ConfigHelper.getLoopModeMaxDelay(getActivity());
    final int maxMovement = ConfigHelper.getLoopModeMaxMovement(getActivity());
    final String info = getString(R.string.loop_mode_info);

    TextView infoText = (TextView) v.findViewById(R.id.loop_mode_info);
    infoText.setText(MessageFormat.format(info, maxMovement, maxDelay));

    final int maxTests = ConfigHelper.getLoopModeMaxTests(getActivity());
    final EditText maxTestsEdit = (EditText) v.findViewById(R.id.loop_mode_max_tests);
    maxTestsEdit.setText(String.valueOf(maxTests));
    maxTestsEdit.setSelection(String.valueOf(maxTests).length());

    Button goButton = (Button) v.findViewById(R.id.loop_mode_start_button);
    goButton.setOnClickListener(new OnClickListener() {

        @Override/*from   w  ww  . jav  a 2s  .  c o m*/
        public void onClick(View v) {
            try {
                boolean startTest = true;
                if (!ConfigHelper.isDevEnabled(getActivity())) {
                    startTest = RMBTPreferenceActivity.checkInputValidity(getActivity(),
                            maxTestsEdit.getText().toString(), AppConstants.LOOP_MODE_MIN_TESTS,
                            AppConstants.LOOP_MODE_MAX_TESTS, R.string.loop_mode_max_tests_invalid);
                }

                if (startTest) {
                    LoopModeStartFragment.this.dismiss();
                    ConfigHelper.setLoopModeMaxTests(getActivity(),
                            Integer.parseInt(maxTestsEdit.getText().toString()));
                    ((RMBTMainActivity) getActivity()).startLoopTest();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    Button goToSettingsButton = (Button) v.findViewById(R.id.loop_mode_go_to_settings_button);
    goToSettingsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            LoopModeStartFragment.this.dismiss();
            ((RMBTMainActivity) getActivity()).showSettings();
        }
    });

    return v;
}

From source file:org.anhonesteffort.flock.SubscriptionStripeFragment.java

private void handleSetupFormForEditingCard() {
    TextView statusView = (TextView) subscriptionActivity.findViewById(R.id.card_subscription_status);
    statusView.setVisibility(View.VISIBLE);

    if (AccountStore.getLastChargeFailed(subscriptionActivity)) {
        statusView.setText(R.string.payment_failed);
        statusView.setTextColor(getResources().getColor(R.color.error_red));
    } else {//from w w  w.  ja  v  a 2s.  c  o m
        statusView.setText(R.string.subscription_is_active);
        statusView.setTextColor(getResources().getColor(R.color.success_green));
    }

    EditText cardNumberView = (EditText) subscriptionActivity.findViewById(R.id.card_number);
    EditText cardExpirationView = (EditText) subscriptionActivity.findViewById(R.id.card_expiration);

    if (cardInformation.isPresent()) {
        if (StringUtils.isEmpty(cardNumberView.getText().toString()))
            cardNumberView.setText("**** **** **** " + cardInformation.get().getCardLastFour());

        if (StringUtils.isEmpty(cardExpirationView.getText().toString()))
            cardExpirationView.setText(cardInformation.get().getCardExpiration());
    }

    Button buttonCancel = (Button) subscriptionActivity.findViewById(R.id.button_card_cancel);
    Button buttonStartSubscription = (Button) subscriptionActivity.findViewById(R.id.button_card_action);

    buttonCancel.setVisibility(View.VISIBLE);
    buttonCancel.setText(R.string.cancel_subscription);
    buttonCancel.setBackgroundColor(getResources().getColor(R.color.error_red));
    buttonCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            handlePromptCancelSubscription();
        }
    });

    buttonStartSubscription.setText(R.string.save_card);
    buttonStartSubscription.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            handleVerifyCardAndPutToServer();
        }
    });

    initCardNumberHelper();
    initCardExpirationHelper();
}

From source file:com.manning.androidhacks.hack041.ArticleActivity.java

private void addCommentPrompt() {
    View body = LayoutInflater.from(this).inflate(R.layout.comment_dialog, null);
    final EditText nameEditText = (EditText) body.findViewById(R.id.name);
    final EditText commentEditText = (EditText) body.findViewById(R.id.comment);

    new AlertDialog.Builder(this).setTitle("Add Comment").setView(body)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override//from  w  ww  .  j ava  2s  .  c  om
                public void onClick(DialogInterface dialogInterface, int i) {
                    String name = nameEditText.getText().toString().trim();
                    String comments = commentEditText.getText().toString().trim();
                    if (!name.equals("") && !comments.equals("")) {
                        insertComment(name, comments);
                    }
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    // do nothing
                }
            }).show();
}

From source file:com.gmail.srivi.sundaram.locgenie.MainActivity.java

public void getSuggestion(View v) {

    if (servicesConnected()) {
        Log.d(" ", "In getSuggestions_new");
        EditText radius = (EditText) findViewById(R.id.editText1);
        String radiusCheck = radius.getText().toString();
        // Getting the Selected Activity
        RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
        RadioButton selected = (RadioButton) findViewById(rg.getCheckedRadioButtonId());
        String activity = (String) selected.getText();
        if (radiusCheck.isEmpty()) {
            Toast.makeText(this, "Please Enter Radius", Toast.LENGTH_SHORT).show();
        } else {/* w ww.j  a va2s .co m*/
            float miles = Float.valueOf(radius.getText().toString());
            float meters = (float) (miles * 1609.344);
            String radiusInMeters = Float.toString(meters);
            Location currentLocation = mLocationClient.getLastLocation();
            Intent intent = new Intent(getBaseContext(), DisplayPlacesActivity.class);
            intent.putExtra(EXTRA_MESSAGE, currentLocation);
            intent.putExtra(RADIUS, radiusInMeters);
            intent.putExtra(ACTIVITY, activity);
            startActivity(intent);
        }

    }
}

From source file:com.attentec.Login.java

/**
 * Make the login button clickable.//from  ww  w.ja  v a2  s. c o  m
 */
private void makeButton() {
    Log.d(TAG, "Making new button");
    Button login = (Button) findViewById(R.id.login_button);

    //Start listening for a click on the login button
    login.setOnClickListener(new OnClickListener() {
        public void onClick(final View viewParam) {
            Log.d(TAG, "Clicked the button");
            //this gets the resources in the xml file and assigns it to a local variable of type EditText
            EditText usernameEditText = (EditText) findViewById(R.id.txt_username);
            EditText passwordEditText = (EditText) findViewById(R.id.txt_password);
            //the getText() gets the current value of the text box
            //the toString() converts the value to String data type
            //then assigns it to a variable of type String
            String sUserName = usernameEditText.getText().toString();
            String sPassword = passwordEditText.getText().toString();

            //Resets key-field upon a failed login attempt

            passwordEditText.setText("");
            //Save the login data for future use in authentication. This will enable the user to login without
            //entering login information again.
            saveKey(sPassword);
            saveUserName(sUserName);

            login(readKey(), readUserName());

        }
    });
}

From source file:com.openerp.addons.note.EditNoteFragment.java

public void createNotetag() {

    AlertDialog.Builder builder = new Builder(scope.context());
    final EditText tag = new EditText(scope.context());
    builder.setTitle("Tag Name").setMessage("Enter new Tag").setView(tag);

    builder.setPositiveButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
            // do something with onClick
            if (tag.getText().length() > 0) {
                LinkedHashMap<String, String> newTag = db.writeNoteTags(tag.getText().toString());
                noteTags.addObject(/*w w  w  .j  a v  a 2  s .c  om*/
                        new TagsItems(Integer.parseInt(newTag.get("newID")), newTag.get("tagName"), ""));
            } else {
                Toast.makeText(scope.context(), "Enter Tag First", Toast.LENGTH_LONG).show();
            }
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
        }
    });

    builder.create().show();
}

From source file:tmnt.wheresyourcar.ParkActivity.java

public void onClick(View view) {
    EditText text = (EditText) findViewById(R.id.license_plate);
    TimePicker num = (TimePicker) findViewById(R.id.num_pick);
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, num.getCurrentHour());
    c.set(Calendar.MINUTE, num.getCurrentMinute());
    Calendar c2 = Calendar.getInstance();
    long minutes = TimeUnit.MILLISECONDS.toMinutes(c.getTimeInMillis() - c2.getTimeInMillis());
    String carID = "";
    if (text.getText().toString().isEmpty()) {
        carID = "Your Car!";
    } else {//from   w w  w  .j  av a2s . c o  m
        carID = text.getText().toString();
    }
    Parking parking = new Parking((int) minutes, carID, getLocation());
    parkCar(parking);

    if (parking.getEnd_time() >= 5) {
        new SendToServer().execute(parking);
    }

    globals.tabState = 1;
    Intent map = new Intent(getApplicationContext(), MainActivity.class);
    startActivity(map);
    finish();
}

From source file:com.nordicsemi.nrfUARTv2.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from w  w w . ja v a  2s . com
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBtAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    messageListView = (ListView) findViewById(R.id.listMessage);
    listAdapter = new ArrayAdapter<String>(this, R.layout.message_detail);
    messageListView.setAdapter(listAdapter);
    messageListView.setDivider(null);
    btnConnectDisconnect = (Button) findViewById(R.id.btn_select);
    btnConnectRight = (Button) findViewById(R.id.button);
    btnSend = (Button) findViewById(R.id.sendButton);
    edtMessage = (EditText) findViewById(R.id.sendText);
    service_init();

    // Handler Disconnect & Connect button
    btnConnectDisconnect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //should not be here, only for debug
            UploadData();
            //                if (!mBtAdapter.isEnabled()) {
            //                    Log.i(TAG, "onClick - BT not enabled yet");
            //                    Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            //                    startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            //                }
            //                else {
            //                    if (btnConnectDisconnect.getText().equals("Connect Left")){
            //
            //                        //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices
            //
            //                        Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class);
            //                        startActivityForResult(newIntent, REQUEST_SELECT_DEVICE);
            //                    } else {
            //                        //Disconnect button pressed
            //                        if (mDevice!=null)
            //                        {
            //                            mService.disconnect();
            //
            //                        }
            //                        if (mDevice2!=null)
            //                        {
            //                            mService2.disconnect();
            //
            //                        }
            //                        mCollecting = false;
            //                        UploadData();
            //                    }
            //                }
        }
    });

    btnConnectRight.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mBtAdapter.isEnabled()) {
                Log.i(TAG, "onClick - BT not enabled yet");
                Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            } else {
                if (btnConnectRight.getText().equals("Connect Right")) {

                    //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices

                    Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class);
                    startActivityForResult(newIntent, REQUEST_SELECT_DEVICE2);
                } else {
                    //Disconnect button pressed
                    if (mDevice2 != null) {
                        mService2.disconnect();

                    }
                }
            }
        }
    });

    // Handler Send button  
    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText editText = (EditText) findViewById(R.id.sendText);
            String message = editText.getText().toString();
            byte[] value;
            try {
                //send data to service
                value = message.getBytes("UTF-8");
                mService.writeRXCharacteristic(value);
                //Update the log with time stamp
                String currentDateTimeString = DateFormat.getTimeInstance().format(new Date());
                listAdapter.add("[" + currentDateTimeString + "] TX: " + message);
                messageListView.smoothScrollToPosition(listAdapter.getCount() - 1);
                edtMessage.setText("");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    });

    // Set initial UI state

}