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:androidx.navigation.testapp.AndroidFragment.java

@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    TextView tv = view.findViewById(R.id.text);
    tv.setText(getArguments().getString("myarg"));

    Button b = view.findViewById(R.id.send_notification);
    b.setOnClickListener(new View.OnClickListener() {
        @Override//ww  w . j av  a2  s  .co m
        public void onClick(View v) {
            EditText editArgs = view.findViewById(R.id.edit_args);
            Bundle args = new Bundle();
            args.putString("myarg", editArgs.getText().toString());
            PendingIntent deeplink = Navigation.findNavController(v).createDeepLink()
                    .setDestination(R.id.android).setArguments(args).createPendingIntent();
            NotificationManager notificationManager = (NotificationManager) requireContext()
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                notificationManager.createNotificationChannel(
                        new NotificationChannel("deeplink", "Deep Links", NotificationManager.IMPORTANCE_HIGH));
            }
            NotificationCompat.Builder builder = new NotificationCompat.Builder(requireContext(), "deeplink")
                    .setContentTitle("Navigation").setContentText("Deep link to Android")
                    .setSmallIcon(R.drawable.ic_android).setContentIntent(deeplink).setAutoCancel(true);
            notificationManager.notify(0, builder.build());
        }
    });
}

From source file:com.privacity.BuscarPerfilActivity.java

public void enviarCodigo(View view) {
    EditText txtv = (EditText) findViewById(R.id.editEnviarCodigo);
    String codigo = txtv.getText().toString();
    JSONObject jsonObject = com.getPerfil(codigo);

    if (!jsonObject.has("Error") && !jsonObject.has("detail")) {
        try {/*from   w  ww.ja va 2  s . c o  m*/
            Intent intent = new Intent(this, PerfilActivity.class);
            intent.putExtra("descripcion", jsonObject.getString("descripcion"));
            intent.putExtra("permisos", jsonObject.getString("permisos"));
            Log.wtf("PERMISOS", jsonObject.getString("permisos"));
            intent.putExtra("usuario", jsonObject.getString("usuario"));
            intent.putExtra("codigo", codigo);
            intent.putExtra("agregado", jsonObject.getString("agregado"));
            startActivity(intent);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.wtf("Error", e);
        }
    } //IF
    else {
        Dialog dialogoError = new Dialog(this);
        try {
            String error = jsonObject.getString("Error");
            dialogoError.setTitle(error);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            dialogoError.setTitle(R.string.Upps);
            e.printStackTrace();
        }
        dialogoError.show();
    }

}

From source file:com.dcs.fakecurrencydetector.MainActivity.java

/**
 * Reads text from EditText// w w  w .j  av a2  s.  c  om
 * 
 * @param input
 * @return
 */
private String readText(EditText input) {
    return input.getText().toString();
}

From source file:at.bitfire.davdroid.ui.CreateAddressBookActivity.java

public void onCreateCollection(MenuItem item) {
    boolean ok = true;
    CollectionInfo info = new CollectionInfo();

    Spinner spinner = (Spinner) findViewById(R.id.home_sets);
    String homeSet = (String) spinner.getSelectedItem();

    EditText edit = (EditText) findViewById(R.id.display_name);
    info.displayName = edit.getText().toString();
    if (TextUtils.isEmpty(info.displayName)) {
        edit.setError(getString(R.string.create_collection_display_name_required));
        ok = false;/*  w  ww.j  a v a  2s.c  om*/
    }

    edit = (EditText) findViewById(R.id.description);
    info.description = StringUtils.trimToNull(edit.getText().toString());

    if (ok) {
        info.type = CollectionInfo.Type.ADDRESS_BOOK;
        info.url = HttpUrl.parse(homeSet).resolve(UUID.randomUUID().toString() + "/").toString();
        CreateCollectionFragment.newInstance(account, info).show(getSupportFragmentManager(), null);
    }
}

From source file:com.andclient.SetupConnectionActivity.java

private void saveSettingsOnClick(View v) {
    int keyboardPort = 0, mousePort = 0;

    EditText et = (EditText) findViewById(R.id.editTextServerIP);
    String ip = et.getText().toString();
    boolean correctIp = InetAddressUtils.isIPv4Address(ip);
    if (!correctIp) {
        Toast.makeText(SetupConnectionActivity.this, "Server IP is not a correct IPv4 address",
                Toast.LENGTH_SHORT).show();
    }//w w  w  . ja v a  2  s.  c  o m

    et = (EditText) findViewById(R.id.editTextMousePort);
    String txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            mousePort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port is not a number", Toast.LENGTH_SHORT)
                    .show();
        }
        if (mousePort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    et = (EditText) findViewById(R.id.editTextKeyboardPort);
    txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            keyboardPort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be an integer", Toast.LENGTH_SHORT)
                    .show();
        }
        if (keyboardPort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (correctIp && mousePort > 0 && keyboardPort > 0) {
        SharedPreferences.Editor editor = mSettings.edit();
        editor.putString(StartActivity.PREF_SERVER_IP, ip).putInt(StartActivity.PREF_MOUSE_PORT, mousePort)
                .putInt(StartActivity.PREF_KEYBOARD_PORT, keyboardPort);

        editor.commit();
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setTextColor(Color.GREEN);
        tv.setText("Settings saved.");
        tv.setVisibility(View.VISIBLE);
    } else {
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setText("Incorrect input data.");
        tv.setTextColor(Color.RED);
        tv.setVisibility(View.VISIBLE);
    }
}

From source file:com.royclarkson.springagram.GalleryAddFragment.java

private String getGalleryDescription() {
    EditText descriptionText = (EditText) this.getActivity().findViewById(R.id.text_description);
    return descriptionText.getText().toString();
}

From source file:com.smapley.vehicle.utils.LicenseKeyboardUtil.java

public String getData() {
    StringBuilder sb = new StringBuilder();
    if (ArrayUtils.isNotEmpty(edits)) {
        for (EditText editText : edits) {
            sb.append(editText.getText().toString());
        }//from   www  . j  ava  2  s. co  m
    }
    return sb.toString();
}

From source file:at.wada811.dayscounter.view.activity.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // catch UncaughtException
    Thread.setDefaultUncaughtExceptionHandler(new CrashExceptionHandler(getApplicationContext()));
    super.onCreate(savedInstanceState);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    setContentView(R.layout.activity_settings);
    ButterKnife.inject(this);
    // Window size dialog
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(params);/*from  w ww. j  a  v a  2s .  c  o m*/
    LogUtils.d();
    // check Crash report
    File file = ResourceUtils.getFile(this, CrashExceptionHandler.FILE_NAME);
    if (file.exists()) {
        startActivity(new Intent(this, CrashReportActivity.class));
        finish();
        return;
    }
    // AppWidgetId
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    LogUtils.d("appWidgetId: " + appWidgetId);

    WidgetModel model = new WidgetModel(this, appWidgetId);
    viewModel = new Widget1x1ViewModel(this, model);
    // Title
    new EditTextBinding(titleEditText).bind(new Func<EditText, String>() {
        @Override
        public String apply(EditText editText) {
            return editText.getText().toString();
        }
    }, viewModel.getTitle(), new EditTextTextChanged() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            titleTextView.setText(viewModel.getTitle().getValue());
        }
    });
    titleEditText.setText(viewModel.getTitle().getValue());
    // Date
    String date = viewModel.getDate().getValue();
    LogUtils.d("date: " + date);
    LocalDateTime dateTime = date != null ? new LocalDateTime(date) : LocalDateTime.now();
    DatePickerBinding datePickerBinding = new DatePickerBinding(datePicker);
    datePickerBinding.bind(new Func<DatePicker, String>() {
        @Override
        public String apply(DatePicker datePicker) {
            return DatePickerUtils.format(datePicker);
        }
    }, viewModel.getDate(), new OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            diffTextView.setText(viewModel.getDiff().getValue());
            diffTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, viewModel.getDiffTextSize().getValue());
            daysTextView.setText(viewModel.getComparison().getValue());
        }
    });
    datePicker.init(dateTime.getYear(), dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth(),
            datePickerBinding.getOnDateChangedListener());
    diffTextView.setText(viewModel.getDiff().getValue());
    diffTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, viewModel.getDiffTextSize().getValue());
    daysTextView.setText(viewModel.getComparison().getValue());

    // Button
    submitButton.setOnClickListener(this);
}

From source file:li.klass.fhem.fragments.SendCommandFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    final View view = inflater.inflate(R.layout.command_execution, container, false);
    Button sendButton = (Button) view.findViewById(R.id.send);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override//  w w  w . j  a  va2 s. com
        public void onClick(View button) {
            EditText editText = (EditText) view.findViewById(R.id.input);
            String command = editText.getText().toString();

            sendCommandIntent(command);
        }
    });

    ListView recentCommandsList = (ListView) view.findViewById(R.id.command_history);
    recentCommandsAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1);
    recentCommandsList.setAdapter(recentCommandsAdapter);
    recentCommandsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            String command = recentCommands.get(position);
            sendCommandIntent(command);
        }
    });

    return view;
}