Sunday, February 16, 2014

How to pass variables Fragment # setArguments (Bundle) to DialogFragment


Original problem from the CSDN quiz channels, more solutions, see: http://ask.csdn.net/questions / 1751

Problem Description:

When performing some action needs to pass variables to DialogFragment, Eclipse suggested I use

Fragment # setArguments (Bundle) do not know how to use?

Solution:

Use newInstance

 static MyDialogFragment newInstance (int num) {
MyDialogFragment f = new MyDialogFragment ();

/ / Supply num input as an argument.
Bundle args = new Bundle ();
args.putInt ("num", num);
f.setArguments (args);

return f;
}



Such acquisition parameters
 @ Override 
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
mNum = getArguments () getInt ("num");.
...
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The reply was deleted administrator at 2013-03-20 12:02:50

Reply:

Reply:

Reply:
Taught ~
Reply:

Reply:
bucuo, thank landlord
Reply:
Learn
Reply:
The reply was deleted administrator at 2013-03-22 08:59:22

Reply:
Learn
Reply:

Reply:
Thanks very useful
Reply:
Thank you hugged A good help
Reply:
Thank you, landlord. . . . . . . . . . . . . . . . . . . .
Reply:
Thank you, just to use and useful

No comments:

Post a Comment