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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:06:37+00:00 2026-05-23T04:06:37+00:00

I want to get user input using a pop-up dialog box. I am able

  • 0

I want to get user input using a pop-up dialog box. I am able to show the dialog box with an EditText, and the user can enter the input. But when I try to get this value, I just get a null.

It’s a simple enough code. I’m probably missing something really elementary here. Not sure what!

private void getUserInput(String prompt) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(prompt);
    final EditText inputBox = new EditText(this);
    builder.setView(inputBox);
    builder.setPositiveButton(android.R.string.ok,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    String str = "";
                    Log.d(DEBUG_TAG, "OK button clicked");
                    if (inputBox.getText() != null) { //PROBLEM: why is inputBox.getText null?? 
                        str = "null";
                    } else {
                        str = inputBox.getText().toString();
                    }
                    Log.d(DEBUG_TAG, "input text >>>" + str);
                    dialog.dismiss();
                }
            });
    builder.show();
}
  • 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-23T04:06:38+00:00Added an answer on May 23, 2026 at 4:06 am

    Where you’ve got

    if (inputBox.getText() != null)
    

    you’re setting str to null, but checking inputBox.getText() is NOT null; shouldn’t that != be == null? (Although, really, you should probably be checking inputBox.getText().equals("").)

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

Sidebar

Related Questions

i want to get the full address of user programatically using c# how can
I'm already using http://php.net/pdo so I can get whatever I want from the user
What I want I have an EditText, where the user can enter a value,
I want to get user input in one page, store that in a php
If I want to get a user input from Console to my Expression Tree.
I want to read user input in Python to get a url (e.g. http://www.google.com
I am using the FreeTextBox.dll to get user input, and storing that information in
I am using spring mvc 3.0 to build an web application. User can get
i want to get the user who login now .. how to do this
If I want to get a user that has the email address of 'me@example.com',

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.