How to replace the space character with another?

3

The title of the question is to understand that it is simple I ask fool, but I would not like to know how to replace the spaces of a EditText with something else, as in the image below:

In the case of the image the spaces are replaced by the gray dots that are before the declarations of the JavaScript variables. If you copy one of the balls and paste it into another EditText , other than that of the editor, the ball becomes a space.

    
asked by anonymous 11.02.2018 / 02:30

1 answer

0

First of all you will need to do a validation. Note that gray dots commonly appear only to the left of the code, not to the right or between the code. You will also need to work on visual formatting. Here's a sampling of how basic logic will work:

EditText textBox = (EditText) findViewById(R.id.textBox);
textBox.addTextChangedListener(new TextWatcher() {

    public void afterTextChanged(Editable s) { }

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

    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if(s.contains(" ")){
            s.replace(" ", ".");
        }
        myOutputBox.setText(s);
    }
});
    
20.02.2018 / 14:05