BreadcrumbLayout——基于TabLayout的Android面包屑视图控件

alunbar 发布于 2016/05/19 11:01
阅读 589
收藏 0
BreadcrumbLayout是一款基于TabLayout的Android面包屑视图控件。


BreadcrumbLayout


用法:


1、添加如下代码到布局文件中:


<com.github.ayvazj.breadcrumblayout.BreadcrumbLayout
        android:id="@+id/breadcrumbLayout"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@android :color/white" />
/>
2、代码:


   // add a breadcrumb
    breadcrumbLayout.addCrumb(breadcrumbLayout.newCrumb().setText("breadcrumb text"));


    // remove a breadcrumb
    breadcrumbLayout.removeCrumbAt(breadcrumbLayout.getCrumbCount() - 1);


    // listen for selections
    breadcrumbLayout.setOnBreadcrumbSelectedListener(new BreadcrumbLayout.OnBreadcrumbSelectedListener() {
        @Override
        public void onBreadcrumbSelected(BreadcrumbLayout.Breadcrumb crumb) {
            if ( crumb.getTag() != null && crumb.getTag() instanceof Pokemon) {
                imageView.setImageResource(((Pokemon)crumb.getTag()).drawableRes);
            }
            else {
                imageView.setImageDrawable(null);
            }
        }


        @Override
        public void onBreadcrumbUnselected(BreadcrumbLayout.Breadcrumb crumb) {


        }


        @Override
        public void onBreadcrumbReselected(BreadcrumbLayout.Breadcrumb crumb) {


        }
    });
Github托管地址:https://github.com/ayvazj/BreadcrumbLayout
本文转载自:http://www.mobile-open.com/2016/941214.html
加载中
返回顶部
顶部