2012-05-31 3 views
1

내 코드에서이 오류가 나타납니다.왜 내 해상도 파일의 색상이 인식되지 않습니까?

오류 : 지정한 이름과 일치하는 리소스가 없습니다 ('background'값 @ color/red '). 당신을 위해 다시 생성됩니다 프로젝트 R.java 파일을 청소하는

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<color name="red">#ff0000</color> 
<color name="green">#00ff00</color> 
<color name="blue">#0000ff</color> 
</resources> 
+1

당신이 파일을 추가하기 때문에 "깨끗한"실행 한 strings.xml의 파일의 exemple 아래

을 colors.xml하지 strings.xml의에 있어야합니다? 때로는 모든 자원을 새로 고치는 데 정리가 필요합니다. – MikeIsrael

답변

1

시도 : 고해상도/값을 colors.xml에,

<TextView 
    android:id="@+id/tv01" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/prizeFund" 
    android:background="@color/red"> 
</TextView> 

그리고 색상 정의 : 여기

내 텍스트 뷰입니다

이클립스에서 프로젝트 ----> 클린 ...

은 또한 자원

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
     <!-- Strings Resources --> 
    <string name="animations">Animations: </string> 
    <string name="compass">Compass: </string> 

    <!-- Colors Resources --> 
    <color name="opaque_white">#FFFFFFFF</color> 
    <color name="gray">#FF888888</color> 
</resources> 
+0

그것을 청소하고 R 클래스를 재생성했지만 여전히 동일한 오류가 발생했습니다. ( – Tiffany

+1

@Tiffany 업데이트 된 답변을 확인하십시오 –

+0

마침내 작동합니다. – Tiffany

관련 문제