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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:34:00+00:00 2026-06-05T06:34:00+00:00

When a user clicks a Button in my App (which is printed in a

  • 0

When a user clicks a Button in my App (which is printed in a SurfaceView), I’d like a text Dialog to appear and I would like to store the result in a String. I’d like the text Dialog to overlay the current screen. How can I do this?

  • 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-05T06:34:01+00:00Added an answer on June 5, 2026 at 6:34 am

    Sounds like a good opportunity to use an AlertDialog.

    As basic as it seems, Android does not have a built-in dialog to do this (as far as I know). Fortunately, it’s just a little extra work on top of creating a standard AlertDialog. You simply need to create an EditText for the user to input data, and set it as the view of the AlertDialog. You can customize the type of input allowed using setInputType, if you need.

    If you’re able to use a member variable, you can simply set the variable to the value of the EditText, and it will persist after the dialog has dismissed. If you can’t use a member variable, you may need to use a listener to send the string value to the right place. (I can edit and elaborate more if this is what you need).

    Within your class:

    private String m_Text = "";
    

    Within the OnClickListener of your button (or in a function called from there):

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Title");
    
    // Set up the input
    final EditText input = new EditText(this);
    // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    builder.setView(input);
    
    // Set up the buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
        @Override
        public void onClick(DialogInterface dialog, int which) {
            m_Text = input.getText().toString();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    
    builder.show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app in which the user clicks a button, triggering an iFrame
In my typical app, the user clicks a button in an aspx page, invokes
How can I force validation when user clicks button? One would think this should
I have 4 text boxes and when the user clicks a button i wish
I want my recaptcha to appear only after user clicks submit button on the
I have an AJAX app. A user clicks a button, and the page's display
In my app, I have a button called EXIT , when the user clicks
I'm creating an app which has a text field & go button on top
i am trying to create an app. When user clicks on the button, it
in my ios app when the user clicks a button it opens email part

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.