to top
Android APIs
public class

FragmentBreadCrumbs

extends ViewGroup
implements FragmentManager.OnBackStackChangedListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.app.FragmentBreadCrumbs

Class Overview

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 Widget_FragmentBreadCrumbs.

Summary

Nested Classes
interface FragmentBreadCrumbs.OnBreadCrumbClickListener Interface to intercept clicks on the bread crumbs. 
[Expand]
Inherited XML Attributes
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
FragmentBreadCrumbs(Context context)
FragmentBreadCrumbs(Context context, AttributeSet attrs)
FragmentBreadCrumbs(Context context, AttributeSet attrs, int defStyle)
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.

[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.app.FragmentManager.OnBackStackChangedListener
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public FragmentBreadCrumbs (Context context)

Added in API level 11

public FragmentBreadCrumbs (Context context, AttributeSet attrs)

Added in API level 11

public FragmentBreadCrumbs (Context context, AttributeSet attrs, int defStyle)

Added in API level 11

Public Methods

public void onBackStackChanged ()

Added in API level 11

Called whenever the contents of the back stack change.

public void setActivity (Activity a)

Added in API level 11

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

public void setMaxVisible (int visibleCrumbs)

Added in API level 11

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

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

public void setOnBreadCrumbClickListener (FragmentBreadCrumbs.OnBreadCrumbClickListener listener)

Added in API level 12

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

Parameters
listener The new listener to set. Replaces any existing listener.

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

Added in API level 11

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 onClick(View) method.

Parameters
title the title for the parent entry
shortTitle the short title for the parent entry
listener the View.OnClickListener to be called when clicked. A null will result in no action being taken when the parent entry is clicked.

public void setTitle (CharSequence title, CharSequence shortTitle)

Added in API level 11

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.

Protected Methods

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

Added in API level 11

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 This is a new size or position for this view
l Left position, relative to parent
t Top position, relative to parent
r Right position, relative to parent
b Bottom position, relative to parent

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Added in API level 11

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 overriden 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 horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.