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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:21:24+00:00 2026-06-18T15:21:24+00:00

Heres the scenario: A user enters a team name into an EditText field, the

  • 0

Heres the scenario:

A user enters a team name into an EditText field, the text of that is then the new name of a TextView (using setText()). If the user has not entered anything into the EditText field yet, the setText() will be the same text property, as declared in the xml file (so basically the default).

So far I have this code and it is not working. When I type anything into the EditText field and click on something else, the TextView does not change.

public void teamNameChange(View view)
{
    TextView team1NameScore = (TextView) findViewById(R.id.team1NameScore);
    EditText team1Name = (EditText) findViewById(R.id.team1Name);

    if (team1Name.getText().toString().isEmpty())
    {
        team1NameScore.setText("Team 1 Score:");
    } else {
        team1NameScore.setText("" +team1Name);
    }
}

Any idea why the text isn’t changing?

EDIT- FINAL WORKING CODE:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final TextView team1NameScore = (TextView) findViewById(R.id.team1NameScore);
    final EditText team1Name = (EditText) findViewById(R.id.team1Name);

    team1Name.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            String newString = team1Name.getText().toString();
            if (!hasFocus) {
                team1NameScore.setText("" + newString);
            }
        }
    });

}
  • 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-18T15:21:25+00:00Added an answer on June 18, 2026 at 3:21 pm

    You should probably do something like this

    final EditText editText = (EditText) findViewById(R.id.editText1);
    final TextView textView = (TextView) findViewById(R.id.textView1);
    
    editText.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                textView.setText("changed");
            }
        }
    });
    

    Knowing that, of course, editText1 & textView1 are horrible variable names.

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

Sidebar

Related Questions

In normal scenario user enters details into form fields and submits data. On submission
Here's the scenario: if this is a user's first time logging into my web
Heres the scenario: I am supposed to make a small site where user can
I am new to Win Forms, I have a scenario here.. When User enter
Here is the scenario: User enters the registration page. After filling out his/her details
Here I am explaining the scenario - The user, after providing a service has
Here's the scenario. When a user's login info is submitted, activityIndicator view is shown.
Here is my scenario. User fills out this large page which is dynamically created
My database has a table that keeps track of the department and user id.
I'm using Grails 2.1.1 with Cucumber and Geb. I have an Auth.feature that contains

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.