gpt4 book ai didi

android - 了解 Android XML @ 前缀

转载 作者:搜寻专家 更新时间:2023-11-01 08:41:38 26 4
gpt4 key购买 nike

我想了解如何解析 android XML 文件中的 @ 符号。

例如:

<item type="layout" name="activity_item_list">@layout/activity_item_twopane</item>

@layout 引用系统中的布局。

<FrameLayout android:id="@+id/item_detail_container" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_weight="3" />

@+id 似乎通过某种魔法以我可以在代码中引用的方式将 ID 添加到系统中:

R.id.activity_item_detail

我的搜索引导我找到一些随机文章,它们似乎无法帮助我理解这些字符是如何被解析的。这些只是被视为某种形式的宏观\我在哪里可以了解更多关于他的信息?

谢谢沃里克

最佳答案

http://developer.android.com/guide/topics/ui/declaring-layout.html你可以阅读:

The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource.

The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file).

There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so: android:id="@android:id/empty"

有帮助吗?

关于android - 了解 Android XML @ 前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32027596/

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