android - How to get the support fragment manager object in fragment without create static field in activity -
hello want phone call getsupportfragmentmanager
in static fragment giving me error.
non static method getsupportfragmentmanager can not referenced in static class.
public static class demofragment extends fragment { public demofragment() { } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment, container, false); homecoming rootview; } @onclick(r.id.button) public void clickbutton() { dialogfragment newfragment = new datepickerfragment(new datepickerlistener() { @override public void ondateset(datepicker view, int year, int month, int day) { } }); newfragment.show(getsupportfragmentmanager(), "datepicker"); // here error } }
to solve created static variable in activity
private static fragmentmanager fragmentmanager;
and assigned oncreate
fragmentmanager = getsupportfragmentmanager();
please help how back upwards fragment manager object in fragment without create static field in activity or right way did.
thanks in advance.
inside fragment can use getfragmentmanager()
.
android android-fragments
No comments:
Post a Comment