Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

FragmentBreadCrumbs

public class FragmentBreadCrumbs
extends ViewGroup implements FragmentManager.OnBackStackChangedListener

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.app.FragmentBreadCrumbs


This class was deprecated in API level 21.
This widget is no longer supported.

Helper class for showing "bread crumbs" representing the fragment stack in an activity. This is intended to be used with ActionBar.setCustomView(View) to place the bread crumbs in the action bar.

The default style for this view is R.style.Widget_FragmentBreadCrumbs.

Summary

Nested classes

interface FragmentBreadCrumbs.OnBreadCrumbClickListener

This interface was deprecated in API level 28. This widget is no longer supported.  

Inherited XML attributes

Inherited constants

Inherited fields

Public constructors

FragmentBreadCrumbs(Context context)
FragmentBreadCrumbs(Context context, AttributeSet attrs)
FragmentBreadCrumbs(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void onBackStackChanged()

Called whenever the contents of the back stack change.

void setActivity(Activity a)

Attach the bread crumbs to their activity.

void setMaxVisible(int visibleCrumbs)

The maximum number of breadcrumbs to show.

void setOnBreadCrumbClickListener(FragmentBreadCrumbs.OnBreadCrumbClickListener listener)

Sets a listener for clicks on the bread crumbs.

void setParentTitle(CharSequence title, CharSequence shortTitle, View.OnClickListener listener)

Inserts an optional parent entry at the first position in the breadcrumbs.

void setTitle(CharSequence title, CharSequence shortTitle)

Set a custom title for the bread crumbs.

Protected methods

void onLayout(boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

Inherited methods

Public constructors

FragmentBreadCrumbs

added in API level 11
public FragmentBreadCrumbs (Context context)

Parameters
context Context

FragmentBreadCrumbs

added in API level 11
public FragmentBreadCrumbs (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

FragmentBreadCrumbs

added in API level 11
public FragmentBreadCrumbs (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

onBackStackChanged

added in API level 11
public void onBackStackChanged ()

Called whenever the contents of the back stack change.

setActivity

added in API level 11
public void setActivity (Activity a)

Attach the bread crumbs to their activity. This must be called once when creating the bread crumbs.

Parameters
a Activity

setMaxVisible

added in API level 11
public void setMaxVisible (int visibleCrumbs)

The maximum number of breadcrumbs to show. Older fragment headers will be hidden from view.

Parameters
visibleCrumbs int: the number of visible breadcrumbs. This should be greater than zero.

setOnBreadCrumbClickListener

added in API level 12
public void setOnBreadCrumbClickListener (FragmentBreadCrumbs.OnBreadCrumbClickListener listener)

Sets a listener for clicks on the bread crumbs. This will be called before the default click action is performed.

Parameters
listener FragmentBreadCrumbs.OnBreadCrumbClickListener: The new listener to set. Replaces any existing listener.

setParentTitle

added in API level 11
public void setParentTitle (CharSequence title, 
                CharSequence shortTitle, 
                View.OnClickListener listener)

Inserts an optional parent entry at the first position in the breadcrumbs. Selecting this entry will result in a call to the specified listener's View.OnClickListener.onClick(View) method.

Parameters
title CharSequence: the title for the parent entry

shortTitle CharSequence: the short title for the parent entry

listener View.OnClickListener: the View.OnClickListener to be called when clicked. A null will result in no action being taken when the parent entry is clicked.

setTitle

added in API level 11
public void setTitle (CharSequence title, 
                CharSequence shortTitle)

Set a custom title for the bread crumbs. This will be the first entry shown at the left, representing the root of the bread crumbs. If the title is null, it will not be shown.

Parameters
title CharSequence

shortTitle CharSequence

Protected methods

onLayout

added in API level 11
protected void onLayout (boolean changed, 
                int l, 
                int t, 
                int r, 
                int b)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view

l int: Left position, relative to parent

t int: Top position, relative to parent

r int: Right position, relative to parent

b int: Bottom position, relative to parent

onMeasure

added in API level 11
protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.