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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:51:38+00:00 2026-06-12T07:51:38+00:00

I need to programmatically create a DialogFragment layout, but I don’t know how to

  • 0

I need to programmatically create a DialogFragment layout, but I don’t know how to proceed. I cannot use xml layout because the DialogFragment will be a part of closed-source JAR file.

Normal Dialogs accept an Activity in their constructor, so it is then possible to instantiate a new Layout like this: layout = new LinearLayout(this);. DialogFragments, on the other hand, do not usually take the Activity as a parameter, so I don’t know how to perform this first step.

  1. How should I create the layout?
  2. Is it OK to ask for an Activity in the constructor?
  3. Is creating a layout of DialogFragment any different from creating a layout of normal Dialog?
    I will be grateful for any other advice regarding manual DialogFragment design.
  • 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-12T07:51:39+00:00Added an answer on June 12, 2026 at 7:51 am

    How should I create the layout?

    How ever you want it to look. If you can’t/don’t want to use a layout file that you inflate and return from the onCreateView method you’ll have to build the entire view hierarchy of your new dialog in code.

    Is it OK to ask for an Activity in the constructor?

    There is no need for this, the Fragment will get a reference to an Activity, you’ll have a reference to that context by using getActivity().

    Is creating a layout of DialogFragment any different from creating a
    layout of normal Dialog? I will be grateful for any other advice
    regarding manual DialogFragment design.

    No, it’s not different. The documentation for the DialogFragment has a great example on how to build a custom DialogFragment, you should check it out.

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

Sidebar

Related Questions

I have a requirement where I need to create a dojox.layout.ContentPane programmatically. function constructContentPane(methodToBeCalled){
I'm using Rails 3 with a MySQL database, and I need to programmatically create
I would really need to programmatically click on all nodes in the collection, but
I need to create all the UI programmatically on demand, this means I can't
I need to create EAN 8 bar code programmatically. I search an algorithm to
In my app I need to create an event in the Calendar programmatically, all
I have a UINavigationController (to use like a wizard page) which I create programmatically
I need to create programmatically a folder named MY_FOLDER in the 'folder /Library/Application Support'.
Does anyone know how I can programmatically create a grid of squares. (each square
I need to create a Firebird Database programmatically using DBExpress. I have done this

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.