Gmail平板电脑(如Actionbar项) [英] Gmail tablet like Actionbar items

查看:66
本文介绍了Gmail平板电脑(如Actionbar项)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用拆分actionbar/toolbar来构建应用,例如在Gmail应用中.

I'm trying to build an app with a split actionbar/toolbar like in the Gmail app.

此行为是否存在任何视图元素,还是我必须自己编写这样的工具栏?

Is there any view element for this behaviour or do I have to write such a toolbar myself?

打开slidingDrawer时,搜索图标随母版fragment一起移动.

The search icon is moving with the master fragment when opening the slidingDrawer.

推荐答案

要实现此目的,您可以添加新的这篇文章很好实施独立工具栏的概述.为了后代的缘故,我在下面提供了示例代码.

To accomplish this you can add one of the new Toolbar widgets to each of your fragments layouts. The new Toolbar class was designed to be much more flexible than a traditional Actionbar and will work well in this split design. This post is a good overview for implementing a standalone Toolbar. For posterity's sake I've included the sample code for it below.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blah);

    Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);

    // Set an OnMenuItemClickListener to handle menu item clicks
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
        // Handle the menu item
        return true;
        }
    });

    // Inflate a menu to be displayed in the toolbar
    toolbar.inflateMenu(R.menu.your_toolbar_menu);
}

这篇关于Gmail平板电脑(如Actionbar项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆