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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:13:29+00:00 2026-05-26T03:13:29+00:00

I have a layout where I have an EditText with a predefined text. Then

  • 0

I have a layout where I have an EditText with a predefined text.

Then I have a button that, when is pressed, displays a dialog with another EditText that gets the text of the previous EditText.

This works fine. But when I edit the first EditText, and press the button again, it displays the old text, not the new.

How can I get the updated text?

This is the code (inside onCreateDialog) where I get the text from the first EditText:

final View notesDialogLayout = getLayoutInflater().inflate(R.layout.notes_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(notesDialogLayout)
       .setCancelable(false)
       .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
           }
       })

AlertDialog alert = builder.create();

mNotesEdit = (EditText) notesDialogLayout.findViewById(R.id.task_notes_dialog);
mNotesEdit.setText(mNotes.getText());

mNotes is just an EditText.

The first time the Dialog opens, it gets the updated text. From the second time, it gets always the same text, even if I edit it.

  • 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-26T03:13:29+00:00Added an answer on May 26, 2026 at 3:13 am

    You are using onCreateDialog. This method is called once only, you must use onPrepareDialog to set your text in the dialog, which is called each time you call showDialog().

    edit

    protected void onCreateDialog(int dialogId) {
        View notesDialogLayout = getLayoutInflater().inflate(R.layout.notes_dialog, null);
        return new AlertDialog.Builder(this)
                .setView(notesDialogLayout)
                .setCancelable(false)
                .setPositiveButton(R.string.save, null)
                .create();
    }
    
    protected void onPrepareDialog(Dialog dialog) {
        EditText content = (EditText) dialog.findViewById(R.id.task_notes_dialog);
        content.setText(mNotes.getText());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this layout that works correctly, a relative layout with a text view
I have an XML layout file that contains an EditText and a Button .
I want to have some layout a bit like this [text tabel][edittext] i cant
I have an Edit Text that is defined as follows. <EditText android:layout_width=fill_parent android:layout_height=wrap_content android:maxLines=1
I have a layout requirement like below, Textview TextView ListView Edit Text Button Since
I have an Activity that displays comments. The comments themselves have a layout, so
I have a layout with a ListView that contains EditText objects that can requestFocus()
I have a layout that uses an EditText to let users search a database
I would like to have a layout that looks like this (in landscape mode):
I have two EditText controls in one TableLayout>TableRow. I have another TableLayout>TableRow that has

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.