gpt4 book ai didi

java - 如何删除 AbsoluteLayout id?

转载 作者:行者123 更新时间:2023-11-30 01:44:48 24 4
gpt4 key购买 nike

为什么声明 android:id="@+id/" 总是在我想运行我的应用程序时出现?有没有办法删除它?谢谢

 <AbsoluteLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/">

错误

Error:(16, 21) Resource id cannot be an empty string (at 'id' with value '@+id/').

我明白了,如果我们要使用它,我们需要设置一个id。如果我删除它并运行,该应用程序仍在运行。但是当我第二次运行时,它再次出现。

最佳答案

The at sign (@) is required when you're referring to any resource object from XML. It is followed by the resource type (id in this case), a slash, then the resource name .

Resource Objects

A resource object is a unique integer name that's associated with an app resource, such as a bitmap, layout file, or string.

Every resource has a corresponding resource object defined in your project's gen/R.java file. You can use the object names in the R class to refer to your resources, such as when you need to specify a string value for the android:hint attribute. You can also create arbitrary resource IDs that you associate with a view using the android:id attribute, which allows you to reference that view from other code.

The SDK tools generate the R.java file each time you compile your app. You should never modify this file by hand.

For more information, read the guide to Providing Resources. The plus sign (+) before the resource type is needed only when you're defining a resource ID for the first time.

你必须设置id

android:id="@+id/Your_id

+id Plus sing tells android to add or create a new id in Resources.

最后

<AbsoluteLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/Your_id">

关于java - 如何删除 AbsoluteLayout id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33888739/

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