Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:54:26+00:00 2026-06-10T05:54:26+00:00

I have an editText , that you write in it something then when u

  • 0

I have an editText, that you write in it something then when u click next .. the text u wrote gets written into another editText ..
It’s working perfectly ..
But I want to use textWatcher to replace some letters..

Example: How do I make the S to be $
or the O to be @

UPDATE:

    final EditText First = (EditText)findViewById(R.id.etFirst);
    String strFirst = First.getText().toString();
    final TextView done = (TextView)findViewById(R.id.tvName);
    String strDone = done.getText().toString();
    Button Trans = (Button) findViewById(R.id.bTrans);

        Trans.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                //First EditText
                if (First.getText().toString().equals("John")) {
                    done.setText("JOHN");
                } else {
                if (First.getText().toString().equals("Ahmed")) {
                    done.setText("AHMED");
                } else  {
                done.setText(First.getText());
                                }
                            }
                        };
                    });

        First.addTextChangedListener(new TextWatcher() {
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

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

            public void afterTextChanged(Editable s) {
            done.setText(First.getText().toString().replaceAll("S", "$"));
            }
            });

my code will type what you wrote in the EditText to a Large TextView below .. when I press the button Trans it sets the text which you wrote but I want to replace some letters example S to $ .. when I type S nothing happens .. just S it don’t gets to be $ ..

What am I doing wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:54:27+00:00Added an answer on June 10, 2026 at 5:54 am

    Assign the Textwatcher to your editText then do something like

    editText.setText(editText.getText().toString().replaceAll("S", "$"));
    

    Here is the textWatcher with code applied

        final EditText First = (EditText)findViewById(R.id.etFirst);
        String strFirst = First.getText().toString();
        final TextView done = (TextView)findViewById(R.id.tvName);
        String strDone = done.getText().toString();
        Button Trans = (Button) findViewById(R.id.bTrans);
    
            Trans.setOnClickListener(new View.OnClickListener() {
    
                public void onClick(View v) {
                    //First EditText
                    if (First.getText().toString().equals("John")) {
                        done.setText("JOHN");
                    } else {
                    if (First.getText().toString().equals("Ahmed")) {
                        done.setText("AHMED");
                    } else  {
                    done.setText(First.getText());
                                    }
                                }
                            };
                        });
    
            First.addTextChangedListener(new TextWatcher() {
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
    
                public void beforeTextChanged(CharSequence s, int start, int count, int after)    {
                }
    
                public void afterTextChanged(Editable s) {
                    String text = First.getText().toString();
                    text = text.replace('s', 'd'); // Any of the diffrent replace methods should work.
                    text = text.replace('S', '$'); // This uses the char replace method. Note, the ' quotations
                    text = text.replace('O', '@');
                    text = text.replace('o', '@');
                    done.setText(text);
                }
            });
    

    Its possible that the error resided in the fact you are getting the old string again, and applying text.replace on it. Rather than the modified string. I would have expected it to have got the new string, but setText doesnt seem to fire immediately.

    So if you get the string into a variable, then apply all your changes. Then put it back to your text box it will work fine. (I have tested and working code here Pasted above)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an EditText , after I write something and I click next i
I have an EditText that the user can write in, when the app starts
I have an EditText that the user can write in, when the app starts
I have two EditText controls in one TableLayout>TableRow. I have another TableLayout>TableRow that has
I have an EditText input that I would like to only allow numbers 1
I have a custom EditText MomentumEditText that I have in a layout in xml
I have an EditText and I want to attach to it a KeyListener that
I have an edittext, and a textwatcher that watches if SPACE arrived or not.
To use as an example: lets say that I have 2 EditText s and
I have a UI that has 6 EditText boxes. 3 of those EditText boxes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.