" setSupportActionBar(toolbar)"在FragmentActivity内部? [英] "setSupportActionBar(toolbar)" inside FragmentActivity?

查看:170
本文介绍了" setSupportActionBar(toolbar)"在FragmentActivity内部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在FragmentActivity内部访问setSupportActionBar(Toolbar toolbar)? 我无法在FragmentActivity

How do I access setSupportActionBar(Toolbar toolbar) inside FragmentActivity? I can't access it inside FragmentActivity

toolbar = (Toolbar) findViewById(R.id.search_bar);
setSupportActionBar( toolbar);

推荐答案

使用最新版本的支持库,您应该使Activity扩展AppCompatActivity,因为已弃用ActionBarActivity.

With the latest version of the support library you should make your Activity extend AppCompatActivity as ActionBarActivity has been deprecated.

它提供与您的ActionBarActivity相同的功能.您不需要进行任何进一步的更改.

It provides the same functionality as your ActionBarActivity previously did. You shouldn't need to make any further changes.

这篇关于" setSupportActionBar(toolbar)"在FragmentActivity内部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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