Example usage for android.widget EditText toString

List of usage examples for android.widget EditText toString

Introduction

In this page you can find the example usage for android.widget EditText toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:nrec.basil.wimuconsole.SensorSettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sensor_settings);

    // Set up the action bar to show a dropdown list which will
    // contain the various sensors that can be configured.  Some
    // sensors are local (camera) some are remote bluetooth devices
    // (IMU, Barometer etc.)
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
            // Specify a SpinnerAdapter to populate the dropdown list.
            new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1,
                    android.R.id.text1, getResources().getStringArray(R.array.sensors_list)),
            this);

    // Specify a SpinnerAdapter to populate the wIMU list
    ArrayAdapter<CharSequence> imuAdapter = ArrayAdapter.createFromResource(this, R.array.wimu_list,
            android.R.layout.simple_spinner_item);
    imuAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    imuSpinner = (Spinner) findViewById(R.id.wimulist);
    imuSpinner.setAdapter(imuAdapter);/*from www. j a v a2  s . c  o  m*/

    // Load the BASIL start/stop/reset commands
    InputStream input = getResources().openRawResource(R.raw.basilstart);
    try {
        input.read(basilStart, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL start command", e);
    }
    input = getResources().openRawResource(R.raw.basilstop);
    try {
        input.read(basilStop, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL stop command", e);
    }
    input = getResources().openRawResource(R.raw.basilreset);
    try {
        input.read(basilReset, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL reset command", e);
    }

    // Get the default filename for logging
    EditText logfilename = (EditText) findViewById(R.id.logfilename);
    mLogFileName = logfilename.toString();

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
}

From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java

/**
 * Display a delete confirmation dialog to remove a device.<br>
 * The user is invited to enter his password to confirm the deletion.
 *
 * @param aDeviceInfoToDelete device info
 *///from   w w w  . j a va  2 s . c om
private void displayDeviceDeletionDialog(final DeviceInfo aDeviceInfoToDelete) {
    if ((null != aDeviceInfoToDelete) && (null != aDeviceInfoToDelete.device_id)) {
        if (!TextUtils.isEmpty(mAccountPassword)) {
            deleteDevice(aDeviceInfoToDelete.device_id);
        } else {
            android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
                    getActivity());
            LayoutInflater inflater = getActivity().getLayoutInflater();
            View layout = inflater.inflate(R.layout.devices_settings_delete, null);

            final EditText passwordEditText = layout.findViewById(R.id.delete_password);
            builder.setIcon(android.R.drawable.ic_dialog_alert);
            builder.setTitle(R.string.devices_delete_dialog_title);
            builder.setView(layout);

            builder.setPositiveButton(R.string.devices_delete_submit_button_label,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (null != mSession) {
                                if (TextUtils.isEmpty(passwordEditText.toString())) {
                                    CommonActivityUtils.displayToast(VectorSettingsPreferencesFragment.this
                                            .getActivity().getApplicationContext(), "Password missing..");
                                    return;
                                }
                                mAccountPassword = passwordEditText.getText().toString();
                                deleteDevice(aDeviceInfoToDelete.device_id);
                            }
                        }
                    });

            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    hideLoadingView();
                }
            });

            builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
                        dialog.cancel();
                        hideLoadingView();
                        return true;
                    }
                    return false;
                }
            });

            builder.create().show();
        }
    } else {
        Log.e(LOG_TAG, "## displayDeviceDeletionDialog(): sanity check failure");
    }
}