FragmentTransaction.java revision 5ae74d6e89a30e79ea85c487b32223ef55314985
1package android.app; 2 3/** 4 * API for performing a set of Fragment operations. 5 */ 6public interface FragmentTransaction { 7 /** 8 * Calls {@link #add(int, Fragment, String)} with a 0 containerViewId. 9 */ 10 public FragmentTransaction add(Fragment fragment, String tag); 11 12 /** 13 * Calls {@link #add(int, Fragment, String)} with a null tag. 14 */ 15 public FragmentTransaction add(int containerViewId, Fragment fragment); 16 17 /** 18 * Add a fragment to the activity state. This fragment may optionally 19 * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView} 20 * returns non-null) into a container view of the activity. 21 * 22 * @param containerViewId Optional identifier of the container this fragment is 23 * to be placed in. If 0, it will not be placed in a container. 24 * @param fragment The fragment to be added. This fragment must not already 25 * be added to the activity. 26 * @param tag Optional tag name for the fragment, to later retrieve the 27 * fragment with {@link Activity#findFragmentByTag(String) 28 * Activity.findFragmentByTag(String)}. 29 * 30 * @return Returns the same FragmentTransaction instance. 31 */ 32 public FragmentTransaction add(int containerViewId, Fragment fragment, String tag); 33 34 /** 35 * Calls {@link #replace(int, Fragment, String)} with a null tag. 36 */ 37 public FragmentTransaction replace(int containerViewId, Fragment fragment); 38 39 /** 40 * Replace an existing fragment that was added to a container. This is 41 * essentially the same as calling {@link #remove(Fragment)} for all 42 * currently added fragments that were added with the same containerViewId 43 * and then {@link #add(int, Fragment, String)} with the same arguments 44 * given here. 45 * 46 * @param containerViewId Identifier of the container whose fragment(s) are 47 * to be replaced. 48 * @param fragment The new fragment to place in the container. 49 * @param tag Optional tag name for the fragment, to later retrieve the 50 * fragment with {@link Activity#findFragmentByTag(String) 51 * Activity.findFragmentByTag(String)}. 52 * 53 * @return Returns the same FragmentTransaction instance. 54 */ 55 public FragmentTransaction replace(int containerViewId, Fragment fragment, String tag); 56 57 /** 58 * Remove an existing fragment. If it was added to a container, its view 59 * is also removed from that container. 60 * 61 * @param fragment The fragment to be removed. 62 * 63 * @return Returns the same FragmentTransaction instance. 64 */ 65 public FragmentTransaction remove(Fragment fragment); 66 67 /** 68 * Hides an existing fragment. This is only relevant for fragments whose 69 * views have been added to a container, as this will cause the view to 70 * be hidden. 71 * 72 * @param fragment The fragment to be hidden. 73 * 74 * @return Returns the same FragmentTransaction instance. 75 */ 76 public FragmentTransaction hide(Fragment fragment); 77 78 /** 79 * Hides a previously hidden fragment. This is only relevant for fragments whose 80 * views have been added to a container, as this will cause the view to 81 * be shown. 82 * 83 * @param fragment The fragment to be shown. 84 * 85 * @return Returns the same FragmentTransaction instance. 86 */ 87 public FragmentTransaction show(Fragment fragment); 88 89 /** 90 * Bit mask that is set for all enter transitions. 91 */ 92 public final int TRANSIT_ENTER_MASK = 0x1000; 93 94 /** 95 * Bit mask that is set for all exit transitions. 96 */ 97 public final int TRANSIT_EXIT_MASK = 0x2000; 98 99 /** Not set up for a transition. */ 100 public final int TRANSIT_UNSET = -1; 101 /** No animation for transition. */ 102 public final int TRANSIT_NONE = 0; 103 /** Window has been added to the screen. */ 104 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK; 105 /** Window has been removed from the screen. */ 106 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK; 107 /** Window has been made visible. */ 108 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK; 109 /** Window has been made invisible. */ 110 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK; 111 /** The "application starting" preview window is no longer needed, and will 112 * animate away to show the real window. */ 113 public final int TRANSIT_PREVIEW_DONE = 5; 114 /** A window in a new activity is being opened on top of an existing one 115 * in the same task. */ 116 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK; 117 /** The window in the top-most activity is being closed to reveal the 118 * previous activity in the same task. */ 119 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK; 120 /** A window in a new task is being opened on top of an existing one 121 * in another activity's task. */ 122 public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK; 123 /** A window in the top-most activity is being closed to reveal the 124 * previous activity in a different task. */ 125 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK; 126 /** A window in an existing task is being displayed on top of an existing one 127 * in another activity's task. */ 128 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK; 129 /** A window in an existing task is being put below all other tasks. */ 130 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK; 131 /** A window in a new activity that doesn't have a wallpaper is being 132 * opened on top of one that does, effectively closing the wallpaper. */ 133 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK; 134 /** A window in a new activity that does have a wallpaper is being 135 * opened on one that didn't, effectively opening the wallpaper. */ 136 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK; 137 /** A window in a new activity is being opened on top of an existing one, 138 * and both are on top of the wallpaper. */ 139 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK; 140 /** The window in the top-most activity is being closed to reveal the 141 * previous activity, and both are on top of he wallpaper. */ 142 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK; 143 144 public FragmentTransaction setCustomAnimations(int enter, int exit); 145 146 public FragmentTransaction setTransition(int transit); 147 public FragmentTransaction setTransitionStyle(int styleRes); 148 149 public FragmentTransaction addToBackStack(String name); 150 public void commit(); 151} 152