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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:44:08+00:00 2026-05-20T05:44:08+00:00

Am very new to Android programming, so sorry if this is a simple problem.

  • 0

Am very new to Android programming, so sorry if this is a simple problem.

I’m trying to create a form to input user data, and I keep getting the following error:

“Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@6279d588”

This is what my xml looks like for the layout:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:isScrollContainer="true"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">"
    <LinearLayout
        android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_gravity="top">
        <TextView
            android:id="@+id/text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="This is a test\nsecond line\n"/>
       <EditText android:id="@+id/name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:maxLength="30"
            android:maxLines="1"
            android:hint="@string/compose_name"></EditText>                  
       <Button
            android:id="@+id/new_contact_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/submit" />

    </LinearLayout>
</ScrollView>

And here is what my class file looks like:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_contact);

        //Set up handlers for input text
        //nameField = (EditText) findViewById(R.id.name);
        //name = nameField.getText().toString();

        final EditText nameField = (EditText) findViewById(R.id.name);
        nameField.setOnKeyListener(new View.OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                (keyCode == KeyEvent.KEYCODE_ENTER)) {
                    String strNicknameToSave = nameField.getText().toString();
                    // TODO: Save Nickname setting (strNicknameToSave)
                    return true;
                }
                return false;
            }
        });

        submitButton = (Button) findViewById(R.id.new_contact_button);

        // Set up click listeners for all the buttons
        submitButton.setOnClickListener(this);

    }

If I get rid of the EditText field, then it works fine. Also it ran perfectly just once, but I haven’t been able to repeat that (all I did in the meantime was delete another layout that isn’t being used).

Thanks for your help.

  • 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-20T05:44:09+00:00Added an answer on May 20, 2026 at 5:44 am
    final EditText nameField = (EditText) findViewById(R.id.name);
    

    Don’t declare nameField as ‘final’ – see if that works.

    EDIT: Ah, OK sorry, I wasn’t thinking straight. Have your Activity implement the listener instead of creating it inline and have nameField as an instance member…

    public class MyActivity extends Activity
        implements View.onKeyListener {
    
        EditText nameField = null; // <-- Instance member
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.new_contact);
    
            nameField = (EditText) findViewById(R.id.name);
            nameField.setOnKeyListener(this);
        }
    
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                (keyCode == KeyEvent.KEYCODE_ENTER)) {
                    String strNicknameToSave = nameField.getText().toString();
                    // TODO: Save Nickname setting (strNicknameToSave)
                    return true;
            }
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still very new to Android, but I am trying to keep up by
I'm very new to Android programming, so this is probably something pretty basic. I
I'm very new to Android programming and I've been trying to figure out why
Allright som first of im very new to android programming and was trying to
I am very new to Android (and mobile) programming. I am trying to test
I am very new to android and I am developing this app which allows
i m new to this android application development i would be very much grateful
I am very new to Java as well as Android programming. I was attempting
Hi I'm new to android programming, I'm trying to initiate the on click method
I am very new to Android programming, and I have read everywhere and 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.