安卓:需要android.support.v7.app.ActionBar发现android.app.ActionBar [英] Android: required android.support.v7.app.ActionBar found android.app.ActionBar

查看:735
本文介绍了安卓:需要android.support.v7.app.ActionBar发现android.app.ActionBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 getActionBar(); 方式,我收到此错误:需要android.support.v7.app.ActionBar发现android.app.ActionBar。我怎样才能解决这个?

I am trying to use the getActionBar(); method and I receive this error: required android.support.v7.app.ActionBar found android.app.ActionBar . How can I correct this?

推荐答案

此错误发生,因为你正在创建一个对象并将它传递给不同的类引用变量。因为 getActionManager android.app.ActionBar 的对象,但您要分配安卓.app.ActionBar 类对象 android.support.v7.app.ActionBar

This error is occurring because you are creating an object and passing it to a different class reference variable. Because getActionManager gives the object of android.app.ActionBar but you are trying to assign android.app.ActionBar class object to android.support.v7.app.ActionBar.

不过,这两个类提供相同的功能。 android.support.v7.app.ActionBar 类是使用时,我们使用的SDK分钟的版本少了API 11获得动作条的下方API 11,我们所需要的对象 android.support.v7.app.ActionBar 类对象。

But both these classes provide the same functionality. android.support.v7.app.ActionBar Class is used when our uses-sdk min version is less the api 11. to get the object of ActionBar below api 11 we need android.support.v7.app.ActionBar class object.

要付诸行动吧,你需要按照以下两种方法之一。

To get Action bar you need to follow one of two approaches.

  1. 进口android.support.v7.app.ActionBar 和使用 getSupportActionBar()方法OD活动

去宴主文件并更改<使用-SDK安卓的minSdkVersion =11机器人:targetSdkVersion =19/> 并导入 ndroid.app.ActionBar和使用getActionBar()

go to main feast file and change <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" /> and import android.app.ActionBar and use getActionBar()

这篇关于安卓:需要android.support.v7.app.ActionBar发现android.app.ActionBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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