Dev Dev - 2 months ago 33
Android Question

Adding Dollar Sign ($) Automatically In Edit Text for Android Studio

I would like to have an edit text that would automatically input a dollar sign before the number. Android Studio



The addition of the $ should take place when the edit text is used (when tapped). The Currency will be in CAD. However the dollar sign will act as a reminder for what the field is


Just add an onChange listener and insert the $ after the user is done input.

private EditText yourEditText;

public void onCreate(Bundle savedInstanceState) {

    yourEditText = (EditText) findViewById(;

    yourEditText.addTextChangedListener(new TextWatcher() {

      public void afterTextChanged(Editable s) {
        yourEditText.setText("$" + yourEditText.getText().toString());

      public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

      public void onTextChanged(CharSequence s, int start, int before, int count) {}