前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >教你轻松几步实现底部导航栏

教你轻松几步实现底部导航栏

作者头像
Hankkin
发布2018-09-06 17:41:16
8380
发布2018-09-06 17:41:16
举报
文章被收录于专栏:Android干货园Android干货园

版权声明:本文为博主原创文章,转载请标明出处。 https://cloud.tencent.com/developer/article/1330981

现在市场上很多app都喜欢底部导航的样式,当然底部导航有很多种方法实现:Fragment、Tabhost等等。最近在网上看到一个比较容易实现的一种方法,真的很简单,下面给大家分享一下:

1.首先导入一个第三方的包:activitycollection.jar(见下)

2.让你的MainActivity继承ActivityCollection

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

//        setContentView(R.layout.activity_main);  要将这句注释掉

        setBottomTabBackground(R.drawable.bottombanner);

//        setDrawableCollections();

    }

@Override

        protected List<IndicatorInfo> setDrawableCollections() {

                // TODO Auto-generated method stub

                List<IndicatorInfo> indicatorInfos = new ArrayList<IndicatorInfo>();

                IndicatorInfo info1 = new IndicatorInfo(R.drawable.icon_1_n, R.drawable.icon_1_c, R.string.home, 12, color.white,new Intent(this,FirstActivity.class));

                IndicatorInfo info2 = new IndicatorInfo(R.drawable.icon_3_n, R.drawable.icon_3_c, R.string.search, 12, color.white,new Intent(this,SecondActivity.class));

                IndicatorInfo info3 = new IndicatorInfo(R.drawable.icon_4_n, R.drawable.icon_4_c, R.string.con, 12, color.white,new Intent(this,ThirdActivity.class));

                indicatorInfos.add(info1);

                indicatorInfos.add(info2);

                indicatorInfos.add(info3);

                return indicatorInfos;

        } 

怎么样是不是很简单的,这样的话可以节省很多空间去让你开发逻辑,而且非常简单哦。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年05月05日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档