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

  • Home
  • SEARCH
  • 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 7678875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:44:49+00:00 2026-05-31T17:44:49+00:00

this is really strange, yesterday I asked the question Yesterdays question how to implement

  • 0

this is really strange, yesterday I asked the question Yesterdays question how to implement multiple editText listeners to avoid duplicating my code. I was kindly provided an answer (which I swear I tried out) but today I am getting no where with it. I am trying to do the following but am getting an Cannot instantiate the type TextWatcher error when trying to setup the tw Textwatcher.

**TextWatcher tw = new TextWatcher();**

intTextValue.addTextChangedListener(tw);

any help would be much appreciated. its starting to drive me a little crazy.

Ultimately I am trying to get to the following situation (which should be simple right??).

public class myClass extends Activity implements OnFocusChangeListener, TextWatcher {
private EditText et;
private EditText et1;
private EditText et2;
private int whoHasFocus= 0;

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout1);


        et = (EditText)findViewById(R.id.et);
        et.setOnFocusChangeListener(this);
        et.addTextChangedListener(tw);

        et1 = (EditText)findViewById(R.id.et);
        et1.setOnFocusChangeListener(this);
        et1.addTextChangedListener(tw);

        et2 = (EditText)findViewById(R.id.et);
        et2.setOnFocusChangeListener(this);
        et2.addTextChangedListener(tw);

}

        @Override
        public void onFocusChange(View v, boolean hasFocus) {

            switch (v.getId()) {
            case R.id.et:
                whoHasFocus =1;
                break;
            case R.id.et1:
                whoHasFocus =2;
                break;
            case R.id.et2:
                whoHasFocus=3;
                break;              
            }


        }

    @Override
    public void afterTextChanged(Editable s) {
        switch (whoHasFocus) {
            case 1:
                //do code
                break;
            case 2:
                //do code
                break;
            case 3:
                //do code
                break;              
            }

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // TODO Auto-generated method stub

    }

}
  • 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-05-31T17:44:50+00:00Added an answer on May 31, 2026 at 5:44 pm

    You don’t need a TextWatcher instance, just use “this”

    et.addTextChangedListener(this);
    et1.addTextChangedListener(this);
    et2.addTextChangedListener(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is really strange but this code is working fine unless the value entered
This is a really strange behavior, and I've set up some demo code to
This is really strange, I'm not sure what could be causing the code to
This is a really strange issue. One day my project started to do a
This is a really strange problem, that appears to be somewhat intermittent (although it
(this is regarding the Ramaze.net framework) I ran into some really strange problems while
I know this has been asked 100 times before but every bit of code
This is a really strange issue. When using WebClient.DownloadFile in Debug configuration, it appears
This is a really strange issue, I am trying to use the Recaptcha on
I have this really strange problem where my entity framework query isn't enumerating correctly.

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.