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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:22:47+00:00 2026-06-12T14:22:47+00:00

To create the dialog, I’m overriding the following method: protected Dialog onCreateDialog(final int dialogId)

  • 0

To create the dialog, I’m overriding the following method:

protected Dialog onCreateDialog(final int dialogId) {
}

and to call this, I’m using:

showDialog(id);

But now I want to use FragmentDialog, but there is no method like:

protected Dialog onCreateDialog(final int dialogId) {
    }

It has

Dialog onCreateDialog(Bundle savedInstanceState){}

My question is, how can I show dialogs based on different id’s in FragmentDialog.

  • 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-12T14:22:49+00:00Added an answer on June 12, 2026 at 2:22 pm

    I guess by FragmentDialog you mean showing Dialogs inside a Fragment and NOT a DialogFragment

    But you can replicate this behavior inside a Fragment Like this:

    class SomeFragment extends Fragment{
    
      HashMap<Integer, Dialog> mDialogs = new HashMap<Integer, Dialog>();
    
      public void showDialog(int dialogId){
    
        Dialog d = mDialogs.get(dialogId);
        if (d == null){
    
          d = onCreateDialog(dialogId);
          mDialogs.put(dialogId, d);
        }
        if (d != null){
           onPrepareDialog(d, dialogId);
           d.show();
        }
    
      }
    
      public Dialog onCreateDialog(int dialogId){
        //just create your Dialog here, once
      }
    
      public void onPrepareDialog(Dialog d, int dialogId){
          super.onPrepareDialog(d, dialogId);
          // change something inside already created Dialogs here
      }
    }
    

    it is just a simple caching of Dialogs

    EDIT: Original Source from Activity:

    /**
     * Show a dialog managed by this activity.  A call to {@link #onCreateDialog(int)}
     * will be made with the same id the first time this is called for a given
     * id.  From thereafter, the dialog will be automatically saved and restored.
     *
     * Each time a dialog is shown, {@link #onPrepareDialog(int, Dialog)} will
     * be made to provide an opportunity to do any timely preparation.
     *
     * @param id The id of the managed dialog.
     *
     * @see Dialog
     * @see #onCreateDialog(int)
     * @see #onPrepareDialog(int, Dialog)
     * @see #dismissDialog(int)
     * @see #removeDialog(int)
     */
    public final void showDialog(int id) {
        if (mManagedDialogs == null) {
            mManagedDialogs = new SparseArray<Dialog>();
        }
        Dialog dialog = mManagedDialogs.get(id);
        if (dialog == null) {
            dialog = createDialog(id, null);
            mManagedDialogs.put(id, dialog);
        }
    
        onPrepareDialog(id, dialog);
        dialog.show();
    }
    
    /**
     * Provides an opportunity to prepare a managed dialog before it is being
     * shown.
     * <p>
     * Override this if you need to update a managed dialog based on the state
     * of the application each time it is shown. For example, a time picker
     * dialog might want to be updated with the current time. You should call
     * through to the superclass's implementation. The default implementation
     * will set this Activity as the owner activity on the Dialog.
     * 
     * @param id The id of the managed dialog.
     * @param dialog The dialog.
     * @see #onCreateDialog(int)
     * @see #showDialog(int)
     * @see #dismissDialog(int)
     * @see #removeDialog(int)
     */
    protected void onPrepareDialog(int id, Dialog dialog) {
        dialog.setOwnerActivity(this);
    }
    
    
    
     /**
     * Callback for creating dialogs that are managed (saved and restored) for you
     * by the activity.
     *
     * If you use {@link #showDialog(int)}, the activity will call through to
     * this method the first time, and hang onto it thereafter.  Any dialog
     * that is created by this method will automatically be saved and restored
     * for you, including whether it is showing.
     *
     * If you would like the activity to manage the saving and restoring dialogs
     * for you, you should override this method and handle any ids that are
     * passed to {@link #showDialog}.
     *
     * If you would like an opportunity to prepare your dialog before it is shown,
     * override {@link #onPrepareDialog(int, Dialog)}.
     *
     * @param id The id of the dialog.
     * @return The dialog
     *
     * @see #onPrepareDialog(int, Dialog)
     * @see #showDialog(int)
     * @see #dismissDialog(int)
     * @see #removeDialog(int)
     */
    protected Dialog onCreateDialog(int id) {
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to create a Dialog box using JQUERY/UI: var $dialog2
I'm trying to create a dialog window using the following CSS: #blackOverlay { display:
I am using jQuery to create a dialog that should show up in the
I create a dialog using JOptionPane manually using the codes below JOptionPane pane =
I want to create a dialog with transparent BG and no border. For this
I'm using jQueryUI to create a dialog, I want the dialog object to be
I'm trying to create a dialog class in WPF. This class inherits from Window
I wanted to create Custom Dialog like the following image which can be called
I need to create a dialog based GUI using VC++/MFC. I am sure it
I'm trying to create a dialog window using JQuery. I'm making progress so far,

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.