gpt4 book ai didi

java - android 中关于 xml 文件的错误。找不到与给定名称 @text 匹配的资源

转载 作者:行者123 更新时间:2023-12-01 14:38:26 25 4
gpt4 key购买 nike

这是我的 about.xml 文件,它是布局文件

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text"
android:id="@+id/abouttextview"></TextView>
</ScrollView>

这是 strings.xml 文件,其中包含单击“关于”按钮时要显示的事项

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Hangman!</string>
<string name="app_name">Android Hangman</string>
<string name="about_text">Hangman is the classic game that has
players
trying to guess their opponent's mystery word first--and
before
getting hanged. For every wrong letter chosen, a bit more
of the hangman is exposed.</string>
<string name="about_title">About Android Hangman</string>
</resources>

我在 about.xml 的 android:text=@strings/about_Text 行收到错误,找不到与给定名称匹配的资源

最佳答案

您需要在strings.xml中的特殊字符之前放置\符号。

对手的

      ^^

string.xml

<string name="about_text">Hangman is the classic game that has
players
trying to guess their opponent\'s mystery word first--and
before
getting hanged. For every wrong letter chosen, a bit more
of the hangman is exposed.</string>

about.xml

<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/abouttextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text" >
</TextView>
</ScrollView>

它适用于我的情况。

关于java - android 中关于 xml 文件的错误。找不到与给定名称 @text 匹配的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16249246/

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