AndroidGreece.gr
https://androidgreece.gr/forum/

Fragment replacment
https://androidgreece.gr/forum/viewtopic.php?f=4&t=11411
Page 1 of 1

Author:  kosaanta [ 28 Apr 2014, 13:04 ]
Post subject:  Fragment replacment

Καλημέρα θα ήθελα να κάνω μια ερώτηση αν μπορείτε να με βοηθήσετε. Έχω ενα fragment με 1 action bar item menu. Το κάνω replace και στο επόμενο fragment ο τίτλος του είναι της μορφής Cust... (αντι για Customer Profile) και αντί για 2 items sto action βαρ μου εμφανίζει μόνο 1. Επίσης δεν μου εμφανίζει τίποτα στο content frame άσπρο background. Αν κάνω rotate την συσκευή η κλείσω και ανοίξω την οθόνη τα φορτώνει όλα κανονικά. Με λίγα λόγια αν κάνει refresh το fragment είναι όλα καλά. Σκέφτομαι μήπως έχει κάποιο θέμα με το πρώτο fragment και σκαλώνουν τα menu και οι τίτπλοι.

Έτσι δημιουργώ το ρχικό fragment:

CustomerProfile fragment = new CustomerProfile();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(getResources().getIdentifier("content_frame", "id", getPackageName()), fragment).commit();

Και έτσι κάνω replace το επόμενο fragment που έχω και το πρόβλημα:

CustomerProfileEdit mProfileEdit = new CustomerProfileEdit();
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.content_frame, mProfileEdit);
ft.addToBackStack(null);
ft.commit();
fm.executePendingTransactions();
getFragmentManager().executePendingTransactions();

Author:  Ultimus [ 16 May 2014, 20:53 ]
Post subject:  Re: Fragment replacment

Καλησπέρα.
Τελικά έλυσες το πρόβλημα; Εκτός του ότι καλείς 2 φορές την executePendingTransactions() δε βλέπω κάτι λάθος στον κώδικα που δείχνεις.

Page 1 of 1 All times are UTC + 2 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/