gpt4 book ai didi

Android 4.0 与 4.2 API 差异

转载 作者:行者123 更新时间:2023-11-29 20:28:43 24 4
gpt4 key购买 nike

我正在尝试为 Android 4.2 设备编程,但我的书是讲授 Android 4.0 的,书名为 Beginning Android App Development 4 .所以,我在运行针对 Android 4.2 的第一个程序时遇到了问题:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first Android Application!" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button!" />

</LinearLayout>

error: Error: No resource found that matches the given name (at 'text' with value '@string/hello'). activity_main.xml /HelloWorld/res/layout line 7 Android AAPT Problem

[I18N] Hardcoded string "And this is a clickable button!", should use @string resource activity_main.xml /HelloWorld/res/layout line 20 Android Lint Problem

[I18N] Hardcoded string "This is my first Android Application!", should use @string resource activity_main.xml /HelloWorld/res/layout line 15 Android Lint Problem

我想知道在哪里可以找到 4.0 API 与 4.2 之间的区别?我应该继续读这本书吗?

最佳答案

好吧,第一个错误只是因为您还没有在 strings.xml 中创建名为 hello 的资源。其他两个警告只是因为 Android Lint 希望您使用字符串资源(如第一个),而不是对字符串进行硬编码。

然而,这些都与 Android 4.0 和 4.2 之间的任何差异无关。

如果您仍然对这些 API 级别的差异感到好奇,Android 文档中有大量信息。

https://developer.android.com/sdk/api_diff/21/changes.html https://developer.android.com/sdk/api_diff/22/changes.html

关于Android 4.0 与 4.2 API 差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32273190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com