【问题标题】:ActionBar in Fragments with back button and logo带有后退按钮和徽标的片段中的 ActionBar
【发布时间】:2016-10-21 13:40:54
【问题描述】:

我有ActivityFirstFragment,这会打开另一个SecondFragment

我想把这个放在我的FirstFragment

我想把这个放在我的SecondFragment

但现在我在他们两个身上都有这个......

我该怎么做?

【问题讨论】:

    标签: android android-studio android-fragments android-actionbar


    【解决方案1】:

    在你的Activity

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setIcon(R.mipmap.ic_launcher); //for example
    

    在你的FirstFragment

     ((ActionBarActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    

    在你的SecondFragment

    ((ActionBarActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    

    【讨论】:

    • 但是我得到了不同的箭头样式,我的带有应用名称的徽标在左侧有一个边距(可能是 40dp),这是不可点击的:/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多