我是 Android 开发新手。
我注意到有时使用 @+id
而不是 @id
。据我所知,显然当你编译一个程序时,它首先扫描源数据并且 @+id
告诉它把 id 添加到 R 文件中,然后它被认为是好的使用 @id
。
是否有用于此的良好做法?理论上我可以总是使用 @+id
来保证安全吗?使用一次 @+id
将其添加到 R,然后删除已经存在的加号怎么样?
或者如果要在其他地方使用 @id
,是否有一种公认的做法是在何处声明 @+id
版本?
最佳答案
我认为一般情况下,如果您将 id 分配给 View @+id
,则指的是 View @id
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/start"
/>
关于android - Android 开发中 @id 与 @+id 用法的公认做法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35809841/