public abstract class FragmentHostCallback<E> extends FragmentContainer
Fragments may be hosted by any object; such as an Activity
. In order to
host fragments, implement FragmentHostCallback
, overriding the methods
applicable to the host.
Constructor and Description |
---|
FragmentHostCallback(Context context,
Handler handler,
int windowAnimations) |
Modifier and Type | Method and Description |
---|---|
void |
onAttachFragment(Fragment fragment)
Called when a
Fragment is being attached to this host, immediately
after the call to its Fragment.onAttach(Context) method and before
Fragment.onCreate(Bundle) . |
void |
onDump(String prefix,
FileDescriptor fd,
PrintWriter writer,
String[] args)
Print internal state into the given stream.
|
View |
onFindViewById(int id)
Return the view with the given resource ID.
|
abstract E |
onGetHost()
Return the object that's currently hosting the fragment.
|
LayoutInflater |
onGetLayoutInflater()
Return a
LayoutInflater . |
int |
onGetWindowAnimations()
Return the window animations.
|
boolean |
onHasView()
Return
true if the container holds any view. |
boolean |
onHasWindowAnimations()
Return
true if there are window animations. |
void |
onInvalidateOptionsMenu()
Invalidates the activity's options menu.
|
void |
onRequestPermissionsFromFragment(Fragment fragment,
String[] permissions,
int requestCode)
Requests permissions from the given fragment.
|
boolean |
onShouldSaveFragmentState(Fragment fragment)
Return
true if the fragment's state needs to be saved. |
void |
onStartActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode,
Bundle options)
Starts a new
Activity from the given fragment. |
void |
onStartIntentSenderFromFragment(Fragment fragment,
IntentSender intent,
int requestCode,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
Bundle options)
Starts a new
IntentSender from the given fragment. |
boolean |
onUseFragmentManagerInflaterFactory()
Return
true if the FragmentManager's LayoutInflaterFactory should be used. |
public void onDump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
prefix
- Desired prefix to prepend at each line of output.fd
- The raw file descriptor that the dump is being sent to.writer
- The PrintWriter to which you should dump your state. This will be closed
for you after you return.args
- additional arguments to the dump request.public boolean onShouldSaveFragmentState(Fragment fragment)
true
if the fragment's state needs to be saved.public LayoutInflater onGetLayoutInflater()
LayoutInflater
.
See Activity.getLayoutInflater()
.public boolean onUseFragmentManagerInflaterFactory()
true
if the FragmentManager's LayoutInflaterFactory should be used.public abstract E onGetHost()
Fragment
is hosted by a Activity
, the object returned here should be the same
object returned from Fragment.getActivity()
.public void onInvalidateOptionsMenu()
Activity.invalidateOptionsMenu()
public void onStartActivityFromFragment(Fragment fragment, Intent intent, int requestCode, Bundle options)
Activity
from the given fragment.
See Activity.startActivityForResult(Intent, int)
.public void onStartIntentSenderFromFragment(Fragment fragment, IntentSender intent, int requestCode, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException
IntentSender
from the given fragment.
See Activity.startIntentSender(IntentSender, Intent, int, int, int, Bundle)
.IntentSender.SendIntentException
public void onRequestPermissionsFromFragment(Fragment fragment, String[] permissions, int requestCode)
Activity.requestPermissions(String[], int)
public boolean onHasWindowAnimations()
true
if there are window animations.public int onGetWindowAnimations()
public void onAttachFragment(Fragment fragment)
Fragment
is being attached to this host, immediately
after the call to its Fragment.onAttach(Context)
method and before
Fragment.onCreate(Bundle)
.public View onFindViewById(int id)
FragmentContainer
null
if the
view is not a child of this container.onFindViewById
in class FragmentContainer
public boolean onHasView()
FragmentContainer
true
if the container holds any view.onHasView
in class FragmentContainer