android - Go back to previous fragment -


btw second fragment. appear once press button in first fragment. in fragment, if press button on phone, go previous fragment. need guys. in advance.

public class listalldoctorfragment extends fragment {     button close;     @nullable     @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view view = inflater.inflate(r.layout.listalldoctor, container,false);          close = (button) view.findviewbyid(r.id.button);          close.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 android.app.fragmentmanager fm = getfragmentmanager();                 fragmenttransaction ft = fm.begintransaction();                 shit f2 = new shit();                 ft.add(r.id.content_frame, f2);                 ft.addtobackstack(null);                 ft.commit();             }           });          return view;      } } 

assuming want go previous fragment, if case, remove ft.addtobackstack(null); code.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -