0
버튼의 텍스트 색상을 변경하기 위해 삼항 연산자를 사용하려고합니다. 다음과 같은 것이 있습니다. 여기에 XML이 있습니다.데이터 바인딩 설정 색상
<Button
android:id="@+id/actionButton"
android:layout_width="113dp"
android:layout_height="30dp"
android:background="@drawable/button"
android:backgroundTint="@{selected ? R.color.white : R.color.turquoise}"
android:text="@{selected ? "Selected " : "Select "}"
android:textColor="@{selected ? @color/white : @color/turquoise}"
android:onClick="@{(view) -> handler.selectClick(view)}"/>
하지만 색상이 올바르게 설정되지 않았습니다. 나는 대신 약간의 사악한 보라색을 얻는다.
나는 같은 결과<import type="com.myapp.R" />
android:textColor="@{selected ? R.color.white : R.color.turquoise}"
을 시도했다.
어떻게해야합니까?
당신은 청록색 색상 요 체크 않았다 올바른 색상 코드를 설정 했습니까? –
예. 색상은 괜찮습니다. android : textColor = "@ color/turquoise"는 필요에 따라 작동합니다. – Shmuel