2012-09-28 2 views
0

이것은 Android 튜토리얼에서 붙여 넣은 코드입니다. 그러나 나는이 3 개의 오류를 얻는다?이클립스 (android hello world app)에서 3 가지 오류가 발생합니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="This is my first Android Application!" /> 

    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="And this is a clickable button!" /> 

</LinearLayout> 

Error: No resource found that matches the given name (at 'text' with value '@string/hello'). main.xml /Helloworld/res/layout line 6 Android AAPT Problem

[I18N] Hardcoded string "And this is a clickable button!", should use @string resource main.xml /Helloworld/res/layout line 17 Android Lint Problem

[I18N] Hardcoded string "This is my first Android Application!", should use @string resource main.xml /Helloworld/res/layout line 13 Android Lint Problem

+1

당신이 입술에 string.xml 파일을 확인 않았다 -> 값이 "안녕하세요"에 포함 폴더 문자열 또는 첫 번째 오류에 대한 ?? – Hemant

답변

1

먼저 하나를 도와주세요. 당신은/입술에 strings.xml의에서 문자열 "안녕하세요"를 정의

<string name="hello">Hello!</string> 

두 세 만 경고이며 값하지 않았습니다. layout.xml은 지역화 될 수 없기 때문에 하드 코딩하지 않아야합니다. "hello"와 같은 기술을 사용해야합니다.

0

@string는 XML 파일을 참조 res/values 폴더에 strings.xml이라고하면 다음과 같이 표시됩니다.

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="hello">Enter your "hello" text you want displayed here</string> 
</resources> 

다른 오류는 위에서 설명한대로 해당 문자열도 만들 것을 제안합니다.

1

이 시도,

String.xml 파일

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
<resources> 
    <string name="hello">Hello World</string> 
    <string name="first_application">This is my first Android Application!</string> 
    <string name="clickable_button">And this is a clickable button!</string> 
</resources> 

당신의 XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/hello"/> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/first_application"/> 
     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/clickable_button"/> 
</LinearLayout>