带有片段的ActionBar(支持)(支持)

编程入门 行业动态 更新时间:2024-10-22 11:39:37
本文介绍了带有片段的ActionBar(支持)(支持)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我还需要在我的一个针对Gingerbread的android应用程序中结合使用操作栏和片段.因此,我使用了v7支持库中的操作栏和v4支持库中的片段,并使用FragmentActivity扩展了我的类.

I need to use a combination of action bar and fragments in one of my android applications that targets Gingerbread too. So I have used the action bar from the v7 support library and fragments from the v4 support library and extend my class with FragmentActivity.

输入行时出现错误

actionbar = getSupportActionBar();

错误指出,对于myFragmentClass 类型(我的类名),未定义 getSupportActionBar().该代码无需支持库即可完美运行.我的问题有解决方案吗?

The error states that getSupportActionBar() is undefined for the type myFragmentClass (my class name). The code works perfectly without the support library. Is there a solution to my problem?

谢谢!

推荐答案

您必须扩展ActionBarActivity而不是FragmentActivity才能使Actionbar带有片段.

You must extend ActionBarActivity instead of FragmentActivity to have Actionbar with fragments.

如果您使用的是v7 appcompat库,则您的活动应扩展ActionBarActivity,它是FragmentActivity的子类(有关更多信息,请参阅添加操作栏).

If you're using the v7 appcompat library, your activity should instead extend ActionBarActivity, which is a subclass of FragmentActivity (for more information, read Adding the Action Bar).

您可以在下面的页面中找到更多信息.上一行来自下面的页面(最后一节). developer.android/training/basics/fragments/creating.html

You can find more info at the page given below.The above line is taken from the page below(Last para). developer.android/training/basics/fragments/creating.html

编辑-这不是错误.它只是缺乏知识.有时基本不清楚.我目前正在android网站上学习,这就是我如何给您答案.

Edit- This is not a bug. Its just lack of knowledge. Sometimes basic are not clear. I am currently learning, that too from the android website, and that's how I got to give you the answer.

更多推荐

带有片段的ActionBar(支持)(支持)

本文发布于:2023-10-16 05:41:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:片段   ActionBar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!