@string & @+id 是什么意思?



@string & @+id 是什么意思?

为什么我们不能在下面使用字符串("假"(而不是false_button?

<Button
        android:id="@+id/false_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/false_button" />

谢谢。

您可以直接使用字符串。

 android:text="False"

@string表示它是存储在字符串.xml文件中的值,参数名称为 false_button 。对于多语言应用,最好这样做。因为您可以为每种语言提供多个 xml 文件,而不是将其硬编码为"False"。

至于@+id,这意味着将带有参数名称的 id 生成到false_button id 查找中。与来自已分配的 id 查找的@id相反。 @+id更好、更快、更易于阅读。

最新更新