无法在android中显示资源中的字符串 我试图显示资源中的字符串

无法在android中显示资源中的字符串 我试图显示资源中的字符串,android,textview,Android,Textview,我已经在values文件夹中显示了字符串的资源 活动\u main.xml <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="4dp" android:paddingRight="4dp" android:paddingTop="10dp" &

我已经在values文件夹中显示了字符串的资源

活动\u main.xml

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="4dp"
        android:paddingRight="4dp"
        android:paddingTop="10dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="140dp"
            android:background="@drawable/frame_background_for_rounded_corners_white_bkg" >

            <ImageView
                android:id="@+id/image1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/image_view_background_white_background" />

            <Button
                android:id="@+id/button1"
                android:layout_width="116dp"
                android:layout_height="wrap_content"
                android:background="@drawable/button_round_cornered_white_background"
                android:text="Button" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="141dp"
                android:layout_alignParentBottom="true"
                android:layout_below="@+id/button1"
                android:gravity="center"
                android:text="@string/BuffetOfferings-Breakfast-statement"
                android:textColor="#000000"
                android:textSize="24sp" />

        </RelativeLayout>
    </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>

<resources>

    <style name="AppTheme" parent="android:Theme.Light" />

    <color name="TextColorForTextAboveImage">#FFFFFF</color>


    <string name="BuffetOfferings-Breakfast-statement">Tap the "Breakfast" to offer, then the days and time of its offerings to your customers</string>


</resources>


在“值”文件夹中


styles.xml

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="4dp"
        android:paddingRight="4dp"
        android:paddingTop="10dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="140dp"
            android:background="@drawable/frame_background_for_rounded_corners_white_bkg" >

            <ImageView
                android:id="@+id/image1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/image_view_background_white_background" />

            <Button
                android:id="@+id/button1"
                android:layout_width="116dp"
                android:layout_height="wrap_content"
                android:background="@drawable/button_round_cornered_white_background"
                android:text="Button" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="141dp"
                android:layout_alignParentBottom="true"
                android:layout_below="@+id/button1"
                android:gravity="center"
                android:text="@string/BuffetOfferings-Breakfast-statement"
                android:textColor="#000000"
                android:textSize="24sp" />

        </RelativeLayout>
    </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>

<resources>

    <style name="AppTheme" parent="android:Theme.Light" />

    <color name="TextColorForTextAboveImage">#FFFFFF</color>


    <string name="BuffetOfferings-Breakfast-statement">Tap the "Breakfast" to offer, then the days and time of its offerings to your customers</string>


</resources>

#FFFFFF
点击要提供的“早餐”,然后点击向客户提供早餐的日期和时间
我的输出

很明显,您可以看到而不是显示文本。。。。引用本身正在显示


如何解决这个问题

您的字符串名称需要使用
\uu
而不是
-

<string name="BuffetOfferings_Breakfast_statement"></string>

您需要从
name
属性中删除破折号(-)

 <string name="BuffetOfferingsBreakfaststatement">Tap the "Breakfast" to offer, then the days and time of its offerings to your customers</string>
点击要提供的“早餐”,然后点击向客户提供早餐的日期和时间

有关详细信息,请阅读。

将资源属性替换为

 <string name="BuffetOfferings_Breakfast_statement">Tap the "Breakfast" to offer, then the days and time of its offerings to your customers</string>
点击要提供的“早餐”,然后点击向客户提供早餐的日期和时间

将连字符'-'替换为下划线''

您不能直接在
styles.xml
中定义字符串,而可以从
strings.xml
引用字符串

您应该在strings.xml中定义字符串,并删除“-”use“

strings.xml
像这样使用

<string name="BuffetOfferings_Breakfast_statement">Tap the "Breakfast" to offer, then the days and time of its offerings to your customers</string>
点击要提供的“早餐”,然后点击向客户提供早餐的日期和时间
希望这对您有所帮助。

尝试去除desh(-)。