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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:09:12+00:00 2026-05-23T10:09:12+00:00

What I am trying to do is update a TextView with each key event

  • 0

What I am trying to do is update a TextView with each key event – basically copying the contents of the EditText to the TextView. For some reason, it’s not working. Here’s the code:

    View.OnKeyListener keyHandler = new OnKeyListener(){

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            TextView id = (TextView)findViewById(R.id.previewEmplIdData);
            TextView fn = (TextView)findViewById(R.id.previewNameData);
            TextView ttl = (TextView)findViewById(R.id.previewTitleData);
            TextView mgr = (TextView)findViewById(R.id.previewMgrData);
            TextView loc = (TextView)findViewById(R.id.previewLocData);
            TextView strt = (TextView)findViewById(R.id.previewStartData);
            String text = "";
            EditText et;
            switch(v.getId()){
            case R.id.etFirstName:
                et = (EditText)v; // must first switch to a text field
                text = et.getText().toString();
                fn.setText(text);
                break;
            case R.id.etLastName:
                et = (EditText)v;
                text = et.getText().toString();
                break;
            case R.id.etEmplId:
                et = (EditText)v;
                text = et.getText().toString();
                id.setText(text);
                break;
            case R.id.etStartDate:
                et = (EditText)v;
                text = et.getText().toString();
                strt.setText(text);
                break;
            case R.id.etTitle:
                et = (EditText)v;
                text = et.getText().toString();
                ttl.setText(text);
                break;
            case R.id.spinnerLocation:
                break;
            case R.id.spinnerManager:
                break;
            }
            return false;
        }
    };

Basically I’m switching through the View id’s on key press, and then casting the view to the EditText. I’m not really sure why this doesn’t work…I’ve always been pretty unlucky with getting switch statements to work. Any help please?

  • 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-23T10:09:13+00:00Added an answer on May 23, 2026 at 10:09 am

    Where do you apply this keyHandler? If you just created and initialized it, but didn’t used in any view, it won’t run at all.

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

Sidebar

Related Questions

I'm trying to update an NText field in SQL 2000 using Classic ASP. Here
Hi I am trying to update a div with some html from another div.
I have been trying to update a TextView field, when i Tap on the
Trying to update some repositories on Debian Etch installation and getting the following errors
I am trying to update the textview in my gallery after it has been
I am trying to update a TextView which will show the system volume. I
Good afternoon everyone So, I'm trying to dynamically change textview's properties. basically, I defined
I'm trying to update the TextView within a custom ListView at a set time
Hello I am trying to update the textview at every certain time, but it
I am trying to get my TextView to update in a separate thread so

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.