android - Can I re-use a DialogFragment instance or should I create I new one for a DatePickerDialog? -


so create datepickerfragment user enter date on edittext line when edittext empty:

@override public void onclick(view v) {    if (xedittext.gettext().length() == 0) {    datepickerfragment newfragment = new datepickerfragment();    newfragment.show(getsupportfragmentmanager(), "datepicker"); } 

later, if edittext not empty (because user entered date) want send date in bundle fragment:

else {      ...              bundle argsbundle = new bundle();      argsbundle.putint("year", c.get(calendar.year));      ... 

my question should create new instance of datepickerfragment named newfragment in else { statement:

else {      ...              bundle argsbundle = new bundle();      argsbundle.putint("year", c.get(calendar.year));      datepickerfragment newfragment = new datepickerfragment();      newfragment.setarguments(argsbundle);      newfragment.show(getsupportfragmentmanager(), "datepicker"); 

or should creating newly named fragment, different newfragment:

     else {      ...              bundle argsbundle = new bundle();      argsbundle.putint("year", c.get(calendar.year));      datepickerfragment secondfragment = new datepickerfragment();      secondfragment.setarguments(argsbundle);      secondfragment.show(getsupportfragmentmanager(), "datepicker"); 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -