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
Post a Comment