Breadcrumb is one of the most important UX term in Web development as well as in Android App development. Breadcrumbs is a control element used as a navigational aid in User Interface in Application or in a website. It allows users to keep track of their locations within Application or websites. 

Here we going to discuss Breadcrumbs with several methods, interface, classes as well with one example.

Class for Breadcrumb in Android

There is Predefine class in Android for Breadcrumb is “FragmentBreadCrumbs”

 

Public Methods for FragmentBreadCrumbs

Some of the methods are followed:-

1. onBackStackChanged

void onBackStackChanged ()

Called whenever the contents of the back stack change.

2. setActivity

void setActivity (Activity a)

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

3. setMaxVisible

void setMaxVisible (int visibleCrumbs)

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

4. setOnBreadCrumbClickListener

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.

5. setParentTitle

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

6. setTitle

added in API level 11
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.

There is only Interface for this class is :-

FragmentManager.OnBackStackChangedListener

Let undersatand BreadCrumbs with an example:-

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    mFragmentManager = getSupportFragmentManager();
    mFragmentManager.addOnBackStackChangedListener(this);

    mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(R.id.breadcrumbs);
    mFragmentBreadCrumbs.setActivity(this);

    mMapFragment = (MapFragment) mFragmentManager.findFragmentByTag("map");
    if (mMapFragment == null) {
        mMapFragment = new MapFragment();
        mMapFragment.setArguments(intentToFragmentArguments(getIntent()));

        mFragmentManager.beginTransaction()
                .add(R.id.fragment_container_map, mMapFragment, "map")
                .commit();
    }

    findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            clearBackStack(getSupportFragmentManager());
        }
    });

    updateBreadCrumb();
}

 

Hope this image will clear all your Quries about Breadcrumb.

BreadCrum.gif

 

Categories: AndroidUX

Ankit

Android Developer Intern

2 Comments

kumars knk · 13/10/2017 at 8:18 AM

Ohh, great to share this information thanks..
I am really happy to say it’s an interesting post to read . I learn new information from your article
Online Marketing in Hyderabad

Leave a Reply

Upcoming weekly website email reporting feature - give feedback.. | Dismiss