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 8545085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:42:42+00:00 2026-06-11T12:42:42+00:00

On PC I can add a onKeyListener for a JTextField to listen keyReleased event.

  • 0

On PC I can add a onKeyListener for a JTextField to listen keyReleased event. On Android I’ve used addTextChangedListener.

I have two EditText fields in my Android application. Editing one will affect the other. This will cause the program to fail in stack overflow error.

How can I listen for the phone’s keyboard instead of changes in the EditText field? I don’t want the program to invoke the listener because of the infinite loop caused by the listener.

  • 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-11T12:42:43+00:00Added an answer on June 11, 2026 at 12:42 pm

    Attach a onFocusChangedListener and add the TextChangedListener when a EditText has focus and remove it when it loses focus.
    Something like this:

     EditText1.setOnFocusChangeListener(new OnFocusChangeListener() {
    
                    public void onFocusChange(View v, boolean hasFocus) {
                        if(hasFocus){
                            ((EditText) v).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) {
                                // affect EditText2
    
                            }
                        });
    
                    }
                    if(!hasFocus){
                        ((EditText) v).removeTextChangedListener();
                    }
                }
            });
    
            }
        });
    

    The same for EditText2

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

Sidebar

Related Questions

I can add a QPixMapImage to a QGraphicsScene, but then I have two issues.
I can add and delete cells to my table view. How to have two
I know one can add event listener for window.error. However when working with Iframes,
How can I add the same text(s) to two or more different lists? For
You can add product to compare. I have to show the link Add to
How can I add elements from two sets? If there's a set one (1,
can any body have any idea if we can add a context menu or
We can add two string class object let's say string str1=hello string str2=world string
I can add two descriptions (attribute) using my IDE, but from Java I can
I can add a child using two methods, one is Canvas.AddVisualChild(Visual); Canvas.AddLogicalChild(Visual); Where i

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.