按钮上的Android文本未显示为Strings.xml

按钮上的Android文本未显示为Strings.xml,android,xml,android-layout,Android,Xml,Android Layout,我正在尝试为我的应用程序中的按钮设置一个简单的字符串。我可以在oncreate中使用button.setText(“文本”),但这太多了。我只想显示我的按钮文本。我将strings.xml文件中的button1字符串设置为文本,但它不想显示。XML图形视图显示按钮上的文本为@strings/button1 <Button android:id="@+id/button1" android:layout_width="wrap_content"

我正在尝试为我的应用程序中的按钮设置一个简单的字符串。我可以在oncreate中使用button.setText(“文本”),但这太多了。我只想显示我的按钮文本。我将strings.xml文件中的button1字符串设置为文本,但它不想显示。XML图形视图显示按钮上的文本为@strings/button1

 <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="19dp"
        android:text="@strings/button1" />



库奇托5K
设置
你好,世界!
一个

从字符串中删除s。它只是@string

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="19dp"
    android:text="@string/button1" />

在xml布局中将
android:text=“@strings/button1”
替换为
android:text=“@string/button1”
。它是字符串而不是字符串。 或者,您可以使用

Button button1 = (Button) findViewById(R.id.button1);
button1.setText("Hi There");
在onCreate()方法中。



试试这个,它应该是@string,而不是@strings

我在其他程序中使用过@strings/text,它当时也可以工作。显示的布局很奇怪。@Jayizzle。如果您使用的是EclipseIDE,请使用crtl+space,按钮显示时不带文本。你能发布那些在@strings/text上运行良好的代码吗?试着这样做:button1.setText(getString(R.string.button1));
Button button1 = (Button) findViewById(R.id.button1);
button1.setText("Hi There");
 <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="19dp"
        android:text="@string/button1" />