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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:53:23+00:00 2026-06-05T17:53:23+00:00

I have this piece of code: public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener listener) {

  • 0

I have this piece of code:

public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener listener) {
    DateDialogFragment dialog = new DateDialogFragment();
    mContext = context;
    mListener = listener;
    /*I dont really see the purpose of the below*/
    Bundle args = new Bundle();
    args.putString("title", "Set Date");
    dialog.setArguments(args);

    return dialog;
}

Pretty self explanatory, but what I don’t understand is what the point of giving it a Bundle. I never really make use of it I guess. The Android Doc’s explanation of this (for Fragments) is here:
http://developer.android.com/reference/android/app/Fragment.html#setArguments(android.os.Bundle)
What exactly does a construction argument mean? Since its never used, I fail to see the use of it. Any explanation much appreciated. Thanks.

  • 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-05T17:53:24+00:00Added an answer on June 5, 2026 at 5:53 pm

    It is simply a generic mechanism for you to attach data values that you might want to use to configure the Fragment or otherwise read during operation, similar to how you might pass extras in a Bundle to a new Activity via it’s Intent.

    I do agree, however, that since a Fragment can be instantiated using its constructor, where an Activity cannot, the usefulness of the API may seem compromised because you can just as easily configure a Fragment using setter methods and member variables inside of newInstance() before returning the instance. For example, your code could implement a method on the Fragment called setTitle() that you could call, and you wouldn’t need to pass that as an argument. However, arguments do provide a nice way of storing this information as key/value data if that model fits your application.

    One key distinction about the arguments of a Fragment is that they are retained as part of the saved instance state. So if your UI rotates or some other change requires the Fragment to be recreated, the arguments Bundle attached will be retained and handed back to the new instance.

    HTH

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

Sidebar

Related Questions

I have written this piece of code public class Test{ public static void main(String[]
I have this piece of code: public static DateTime calcMondayDate(DateTime input) { int delta
I have this piece of code to make an asynchronous HTTP request: public static
I have this piece of code: class Test { public static void main (String[]
I have got this piece of code: public class ThreadInteraction { public static void
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
Hi all I have a piece of code which looks like this: public class
I have this piece of code for reading from an excel cell: public T
I am a bit confused about this piece of code. public static void Foo(A
I have the following piece of code public static void main(String[] args) { ArrayList<Integer>

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.