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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:07:42+00:00 2026-06-05T14:07:42+00:00

I am trying to get text field value from a pop up on clicking

  • 0

I am trying to get text field value from a pop up on clicking Save button. But it is throwing errors.

Code :-

final Button btn_ContactDetails = (Button)findViewById(R.id.btn_ContactDetails);
btn_ContactDetails.setOnClickListener(new Button.OnClickListener(){

    public void onClick(View arg0) {
        LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.contactdetails, null, true);

        final PopupWindow popUp = new PopupWindow(layout, LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT, true);
        popUp.setBackgroundDrawable(new BitmapDrawable());
        popUp.setOutsideTouchable(true);
        popUp.setTouchInterceptor(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popUp.dismiss();
                    return true;
                }
                return false;
            }
        });

        Button btnDismiss = (Button)layout.findViewById(R.id.dismiss);
            btnDismiss.setOnClickListener(new Button.OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    popUp.dismiss();
                }
            });

        //On click Save - Contact Details
        Button btn_Save_ContactDetails = (Button)layout.findViewById(R.id.btn_Save_ContactDetails);
        btn_Save_ContactDetails.setOnClickListener(new Button.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                EditText mEdit, sEdit;
                mEdit = (EditText)findViewById(R.id.txt_HouseNameNumber);
                sEdit = (EditText)findViewById(R.id.txt_Address1);
                sEdit.setText(mEdit.getText().toString());//THIS LINE IS THROWING ERROR
                popUp.dismiss();
            }
        });
        popUp.showAtLocation(layout, Gravity.CENTER, 0, 0);
    }
});

Error :-

06-12 03:21:37.828: E/AndroidRuntime(518): FATAL EXCEPTION: main
06-12 03:21:37.828: E/AndroidRuntime(518): java.lang.NullPointerException
06-12 03:21:37.828: E/AndroidRuntime(518):  at sai.om.SaiActivity$3$3.onClick(SaiActivity.java:171)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.view.View.performClick(View.java:2408)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.view.View$PerformClick.run(View.java:8816)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.os.Handler.handleCallback(Handler.java:587)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.os.Looper.loop(Looper.java:123)
06-12 03:21:37.828: E/AndroidRuntime(518):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-12 03:21:37.828: E/AndroidRuntime(518):  at java.lang.reflect.Method.invokeNative(Native Method)
06-12 03:21:37.828: E/AndroidRuntime(518):  at java.lang.reflect.Method.invoke(Method.java:521)
06-12 03:21:37.828: E/AndroidRuntime(518):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-12 03:21:37.828: E/AndroidRuntime(518):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-12 03:21:37.828: E/AndroidRuntime(518):  at dalvik.system.NativeStart.main(Native Method)

Can anyone help me find what I am doing wrong here?
I have provided comments to the line throwing error.

  • 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-05T14:07:44+00:00Added an answer on June 5, 2026 at 2:07 pm
    sEdit.setText( mEdit.getText());//THIS LINE IS THROWING ERROR
    

    The most likely reason is that either sEdit or mEdit is null (or both).

    Double check your layout file to make sure you have EditTexts with ids of txt_HouseNameNumber and txt_Address1. In other words, make sure they’re spelt correctly and remember case-sensitivity.

    EDIT: Perhaps you should be using layout.findViewById(...) as follows?…

    mEdit = (EditText)layout.findViewById(R.id.txt_HouseNameNumber);
    sEdit = (EditText)layout.findViewById(R.id.txt_Address1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to get a value from a text field (entered by the users)
I'm trying to append a value (quantity) from a text input field to a
I am trying to get the value of the text in the input fields.
I am trying to get text input from the keyboard in Java 6. I
I'm trying to get the text from a textbox as a user types, so
I'm trying to get the plain text from a word document. Specifically, the xpath
I am trying to get a input text area and a submit button attached
I'm trying to get the selected value from a drop down list via jQuery.
I'm trying to get the a tag below to grab the value from the
I am trying to get a value from salesforce class into a javascript variable.

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.