FragmentTransaction.java revision b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23
12dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackbornpackage android.app; 22dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn 32dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn/** 42dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn * API for performing a set of Fragment operations. 5b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * 6b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <div class="special reference"> 7b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <h3>Developer Guides</h3> 8b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <p>For more information about using fragments, read the 9b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <a href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> developer guide.</p> 10b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * </div> 112dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn */ 12ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackbornpublic abstract class FragmentTransaction { 135ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 145ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #add(int, Fragment, String)} with a 0 containerViewId. 155ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 16ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(Fragment fragment, String tag); 175ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 185ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 195ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #add(int, Fragment, String)} with a null tag. 205ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 21ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(int containerViewId, Fragment fragment); 225ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 235ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 245ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Add a fragment to the activity state. This fragment may optionally 255ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView} 265ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * returns non-null) into a container view of the activity. 275ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 285ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param containerViewId Optional identifier of the container this fragment is 295ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * to be placed in. If 0, it will not be placed in a container. 305ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be added. This fragment must not already 315ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be added to the activity. 325ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param tag Optional tag name for the fragment, to later retrieve the 33247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * fragment with {@link FragmentManager#findFragmentByTag(String) 34247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * FragmentManager.findFragmentByTag(String)}. 355ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 365ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 375ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 38ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag); 395ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 405ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 415ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #replace(int, Fragment, String)} with a null tag. 425ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 43ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction replace(int containerViewId, Fragment fragment); 445ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 455ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 465ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Replace an existing fragment that was added to a container. This is 475ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * essentially the same as calling {@link #remove(Fragment)} for all 485ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * currently added fragments that were added with the same containerViewId 495ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * and then {@link #add(int, Fragment, String)} with the same arguments 505ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * given here. 515ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 525ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param containerViewId Identifier of the container whose fragment(s) are 535ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * to be replaced. 545ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The new fragment to place in the container. 555ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param tag Optional tag name for the fragment, to later retrieve the 56247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * fragment with {@link FragmentManager#findFragmentByTag(String) 57247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * FragmentManager.findFragmentByTag(String)}. 585ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 595ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 605ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 61ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag); 625ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 635ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 645ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Remove an existing fragment. If it was added to a container, its view 655ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * is also removed from that container. 665ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 675ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be removed. 685ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 695ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 705ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 71ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction remove(Fragment fragment); 72f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 73f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** 745ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Hides an existing fragment. This is only relevant for fragments whose 755ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * views have been added to a container, as this will cause the view to 765ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be hidden. 775ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 785ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be hidden. 795ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 805ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 815ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 82ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction hide(Fragment fragment); 835ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 845ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 85baa1553c8d125a55956d1a8b2966ccd100673179Jim Shuma * Shows a previously hidden fragment. This is only relevant for fragments whose 865ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * views have been added to a container, as this will cause the view to 875ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be shown. 885ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 895ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be shown. 905ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 915ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 925ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 93ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction show(Fragment fragment); 942b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 952b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 9647c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * Detach the given fragment from the UI. This is the same state as 9747c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * when it is put on the back stack: the fragment is removed from 9847c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * the UI, however its state is still being actively managed by the 9947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * fragment manager. When going into this state its view hierarchy 10047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * is destroyed. 10147c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 10247c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @param fragment The fragment to be detached. 10347c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 10447c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @return Returns the same FragmentTransaction instance. 10547c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn */ 10647c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn public abstract FragmentTransaction detach(Fragment fragment); 10747c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn 10847c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn /** 10947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * Re-attach a fragment after it had previously been deatched from 11047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * the UI with {@link #detach(Fragment)}. This 11147c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * causes its view hierarchy to be re-created, attached to the UI, 11247c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * and displayed. 11347c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 11447c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @param fragment The fragment to be attached. 11547c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 11647c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @return Returns the same FragmentTransaction instance. 11747c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn */ 11847c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn public abstract FragmentTransaction attach(Fragment fragment); 11947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn 12047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn /** 1212b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return <code>true</code> if this transaction contains no operations, 122c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * <code>false</code> otherwise. 1232b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 124ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract boolean isEmpty(); 1255ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 1265ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 1275ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Bit mask that is set for all enter transitions. 128f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn */ 129ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_ENTER_MASK = 0x1000; 130f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 131f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** 132f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn * Bit mask that is set for all exit transitions. 133f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn */ 134ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_EXIT_MASK = 0x2000; 135f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 136f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** Not set up for a transition. */ 137ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_UNSET = -1; 138f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** No animation for transition. */ 139ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_NONE = 0; 1409ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase /** Fragment is being added onto the stack */ 141ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_FRAGMENT_OPEN = 1 | TRANSIT_ENTER_MASK; 1429ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase /** Fragment is being removed from the stack */ 143ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_FRAGMENT_CLOSE = 2 | TRANSIT_EXIT_MASK; 144327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn /** Fragment should simply fade in or out; that is, no strong navigation associated 145327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn * with it except that it is appearing or disappearing for some reason. */ 146327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn public static final int TRANSIT_FRAGMENT_FADE = 3 | TRANSIT_ENTER_MASK; 147811ed1065f39469cf2cf6adba22cab397ed88d5eChet Haase 148c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 149c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set specific animation resources to run for the fragments that are 150bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * entering and exiting in this transaction. These animations will not be 151bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * played when popping the back stack. 152c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 153ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setCustomAnimations(int enter, int exit); 154bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase 155bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase /** 156bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * Set specific animation resources to run for the fragments that are 157bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * entering and exiting in this transaction. The <code>popEnter</code> 158bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * and <code>popExit</code> animations will be played for enter/exit 159bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * operations specifically when popping the back stack. 160bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase */ 161bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase public abstract FragmentTransaction setCustomAnimations(int enter, int exit, 162bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase int popEnter, int popExit); 163bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase 164c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 165c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Select a standard transition animation for this transaction. May be 166c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN}, 167c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * or {@link #TRANSIT_FRAGMENT_CLOSE} 168c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 169ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setTransition(int transit); 170c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 171c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 172c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set a custom style resource that will be used for resolving transit 173c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * animations. 174c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 175ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setTransitionStyle(int styleRes); 176f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 177c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 178c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Add this transaction to the back stack. This means that the transaction 179c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * will be remembered after it is committed, and will reverse its operation 180c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * when later popped off the stack. 181c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 182c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param name An optional name for this back stack state, or null. 183c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 184ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction addToBackStack(String name); 185dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn 186dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn /** 1870c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Returns true if this FragmentTransaction is allowed to be added to the back 1880c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * stack. If this method would return false, {@link #addToBackStack(String)} 1890c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * will throw {@link IllegalStateException}. 1900c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * 1910c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * @return True if {@link #addToBackStack(String)} is permitted on this transaction. 1920c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 193ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract boolean isAddToBackStackAllowed(); 1940c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 1950c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 1960c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Disallow calls to {@link #addToBackStack(String)}. Any future calls to 1970c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * addToBackStack will throw {@link IllegalStateException}. If addToBackStack 1980c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * has already been called, this method will throw IllegalStateException. 1990c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 200ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction disallowAddToBackStack(); 2010c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 2020c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 203c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set the full title to show as a bread crumb when this transaction 204c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * is on the back stack, as used by {@link FragmentBreadCrumbs}. 205c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 206c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param res A string resource containing the title. 207c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 208ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbTitle(int res); 209c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 210c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 211c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Like {@link #setBreadCrumbTitle(int)} but taking a raw string; this 212c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * method is <em>not</em> recommended, as the string can not be changed 213c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * later if the locale changes. 214c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 215ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbTitle(CharSequence text); 216c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 217c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 218c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set the short title to show as a bread crumb when this transaction 219c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * is on the back stack, as used by {@link FragmentBreadCrumbs}. 220c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 221c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param res A string resource containing the title. 222c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 223ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbShortTitle(int res); 224c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 225c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 226c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Like {@link #setBreadCrumbShortTitle(int)} but taking a raw string; this 227c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * method is <em>not</em> recommended, as the string can not be changed 228c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * later if the locale changes. 229c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 230ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbShortTitle(CharSequence text); 231c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 232c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 233ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * Schedules a commit of this transaction. The commit does 234dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * not happen immediately; it will be scheduled as work on the main thread 235dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * to be done the next time that thread is ready. 236dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * 237ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * <p class="note">A transaction can only be committed with this method 238ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * prior to its containing activity saving its state. If the commit is 239ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * attempted after that point, an exception will be thrown. This is 240ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * because the state after the commit can be lost if the activity needs to 241ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * be restored from its state. See {@link #commitAllowingStateLoss()} for 242ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * situations where it may be okay to lose the commit.</p> 243ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * 244dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * @return Returns the identifier of this transaction's back stack entry, 245dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * if {@link #addToBackStack(String)} had been called. Otherwise, returns 246dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * a negative number. 247dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn */ 248ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract int commit(); 249ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn 250ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn /** 251ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * Like {@link #commit} but allows the commit to be executed after an 252ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * activity's state is saved. This is dangerous because the commit can 253ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * be lost if the activity needs to later be restored from its state, so 254ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * this should only be used for cases where it is okay for the UI state 255ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * to change unexpectedly on the user. 256ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn */ 257ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract int commitAllowingStateLoss(); 2582dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn} 259