2014-11-30 2 views
0

여기에 게시 된 몇 가지 질문을 찾았지만 지금까지 아무 것도 작동하지 않아서 내 자신에게 물어 보았습니다. 계속 "주어진 이름과 일치하는 리소스를 찾을 수 없습니다 ('텍스트'값 '@ 문자열/button_name')." 이것은 내 strings.xml의입니다XML/Android : 주어진 이름 오류와 일치하는 리소스가 없습니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.app2.MainActivity" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/req_input" /> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="39dp" 
     android:ems="10" 
     android:inputType="number" > 

     <requestFocus /> 
    </EditText> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/editText1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="20dp" 
     android:text="@strings/button_name" 
     /> 

</RelativeLayout> 

:이 .xml 파일에 대한 오류 (오류가 버튼 태그의 마지막 줄에)

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

    <string name="app_name">App2</string> 
    <string name="hello_world">Hello world!</string> 
    <string name="action_settings">Settings</string> 
    <string name="req_input">Please input the number</string> 
    <string name="button_name">Squared</string> 

</resources> 

strings.xml의 값 디렉토리에 위치하고있는 res 디렉토리 안에 있습니다. 나는 android:text="@strings/button_name"android:text="@+strings/button_name"으로 변경하려고했지만 버튼 텍스트 대신 "Squared"라고 말하면 "false"라고 말합니다. strings.xml에 대한 다른 모든 참조는 정상적으로 작동합니다. Android 프로그래밍이 처음이므로 가능한 한 간단하게 설명하십시오.

+4

'@ 문자열'이 아닌 @ @ 문자열입니다. –

답변

1

변경 @strings/button_name에서 @string/button_name으로 변경하면 문제가 해결됩니다.

+0

와우. 나는 무엇이 잘못되었는지를 알아 내려고 적어도 30 분을 보냈고 한 글자 만 지울 필요가있었습니다. 도와 줘서 고마워. –

+0

환영합니다! 문제가 해결되면 제 대답을 받아주십시오. :) –

관련 문제