2011-08-02 10 views
0

버튼을 클릭하면 다른 레이아웃으로 변경되는 응용 프로그램을 만들고 있습니다. 모두 잘 작동하지만 2 레이아웃의 배경에있는 텍스트 뷰 스타일을 때, 그것은 충돌과 이클립스가 충돌 나던 때 여기 Textview 배경을 사용자 정의하면 응용 프로그램이 충돌합니다.

가 텍스트 뷰의 XML입니다 "소스를 찾을 수 없습니다"라는 :

<TextView android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_width="wrap_content" android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" android:layout_marginTop="15dp" 
    android:id="@+id/licenseKey" android:typeface="monospace" 
    android:text="@string/loading" /> 

을 여기가 충돌 할 때 :

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.register); 

    TextView licenseKey = (TextView)findViewById(R.id.licenseKey); 
    licenseKey.setText(generateKey()); 
} 

public String generateKey() { 
    return "D5JO4-7VQP8-D7B3X-L8N0D"; 
} 

: 여기

<TextView android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_width="wrap_content" android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" android:layout_marginTop="15dp" 
    android:id="@+id/licenseKey" android:typeface="monospace" 
    android:text="@string/loading" android:background="@string/grey"/> 

이 활동 코드 문제가 무엇인지 심각하게 이해하기 어렵습니다. textview는 일반적으로 가짜 라이센스 코드를 보여 주지만 배경을 변경하면 충돌이 발생합니다. 나는 심지어 두 번째 레이아웃을 보지 못한다. 내 Nexus S Android 2.3.3에서 디버깅하기.

답변

0

android : background 속성을 문자열이 아닌 drawable 또는 rgb 값으로 설정해야합니다. here을 참조하십시오. 예 : android:background="#bebebe".

+0

어떻게 문자열에 내가 다른 개체에 대해 동일한 색상뿐 아니라 하나를 사용할 수 대신 그래서 둘 것? – Qasim

0
android:background="@string/grey" 

는이 있어야하지

android:background="@android:color/gray" 
관련 문제