编译错误使用API​​ 10

编程入门 行业动态 更新时间:2024-10-26 06:31:59
本文介绍了编译错误使用API​​ 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我下面就developers.android的基本教程,并通过创建一个名为DisplayMessageActivity活动来了。它与给定的如本教程中的所有规范空白的活动。仅供参考,我使用敏SDK API = 8,目标SDK API = 16,与编译API = 10

I was following the basic tutorials on developers.android and came by creating the activity named DisplayMessageActivity. It is a blank activity with all the specifications given as shown in the tutorial. FYI, I am using Min SDK = API 8, Target SDK = API 16, Compile with = API 10

接下来的事情是,有两个误区:

The next thing is that there are two errors:

  • 的方法getActionBar()是未定义的类型DisplayMessageActivity
  • 家不能得到解决或不是场
  • 我试图改变API至14即要求另一个问题是,它想要的最低API为11。

    I tried changing the API to 14 which called for another problem, it wants the minimum API to be 11.

    这解决了这些问题,但主要的问题是这么多的设备仍然使用姜饼或者升级Froyo。我能不能为他们写?我必须继续走高?如何为他们写?

    That solves these problems, but the main problem is so many devices still use Gingerbread or maybe FroYo. Can't I write for them? Do I have to go higher? How to write for them?

    推荐答案

    首先,你会想要确保你正在编译针对Android的最新版本。因为你编译API 10,但瞄准如果你这样做16的东西可能会破坏你应该更新你的SDK版本,因此最好保持更新是安全的。这意味着,在Eclipse项目右击,点击属性,然后在Android上点击。勾选最高版本的API,它是存在的。如果您有最新的版本,它的是Android 4.2。然后在你的Andr​​oidManifest.xml中,将的android:targetSdkVersion 来你选择什么(我的情况API 17)。

    First, you're going to want to make sure that you are compiling against the latest version of Android. You should update your sdk version because you're compiling for API 10 but targeting 16. Stuff may break if you do that, so it's best to stay updated to be safe. This means right clicking on your project in Eclipse, clicking on Properties then clicking on Android. Check off the highest version API that is there. If you have the latest version, it is Android 4.2. Then in your AndroidManifest.xml, set the android:targetSdkVersion to what you chose (my case api 17).

    这应确保你的应用基本上可以运行在蜂巢中软糖。不过,这个程序要至少升级Froyo运行。这下一部分将让您的应用程序在所有设备上运行。

    This should ensure that your app can run on basically HoneyComb to JellyBean. However, this app wants to run on at least froyo. This next part will allow your app to run on all devices.

    请这样的方法:

    @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Show the Up button in the action bar. getActionBar().setDisplayHomeAsUpEnabled(true); } }

    据检查,看看它在运行的API且仅当它是蜂窝状及以上,使操作栏。从的onCreate()您将需要拿出getActionBarCall即在的onCreate()调用它,因为它不是需要再有。

    It checks to see which API it is running on and only if it is honeycomb and above, enables the action bar. Call it from onCreate() You will need to take out the getActionBarCall that is in onCreate() as it is not needed anymore there.

    至于家里没有被启用,它可能刚刚被一个错误的项目目标,或者你忘了写 android.R.id.home ,而是写了 R.id.home 。

    As for home not being enabled, it might have just been a wrong project target or you forgot to write android.R.id.home and instead wrote R.id.home.

    最后所有这些变化,你应该清理项目(项目 - >清除)

    Lastly with all these changes you should clean your project (Project -> Clean).

    更多推荐

    编译错误使用API​​ 10

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

    发布评论

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

    >www.elefans.com

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