0
다소 간단한 코드가 있습니다. layoutBIds 배열 내의 각 항목을 살펴보고 이에 따라 배경색을 설정합니다.setBackgroundColor()가 작동하지 않는 것처럼 보입니다.
setBackgroundColor는 bidLayouts에서 완벽하게 작동합니다. 내가
BidDriverPrice.setBackgroundColor(getResources().getColor(R.color.Chartreuse));
를 호출 할 때
그러나 해당보기 작동하지 않습니다. 나는 setBackgroundResource를 시도하고 심지어 Google 검색 결과의 처음 세 페이지에서 하나의 비슷한 질문을하므로 나는 뭔가를 놓치고 있다고 확신한다.
for (int i = 0; i < layoutBids.getChildCount(); i++) {
View v = layoutBids.getChildAt(i);
RelativeLayout bidLayouts = (RelativeLayout) v.findViewById(R.id.bidlayout);
final TextView BidDriverPrice = (TextView) v.findViewById(R.id.BidDriverPrice);
final TextView BidDriverMins = (TextView) v.findViewById(R.id.BidDriverPrice1);
if (rgxBidOffer.size() != 0) {
if (rgxBidOffer.get(Integer.parseInt(v.getTag().toString())).seconds > 0) {
bidLayouts.setBackgroundColor(ContextCompat.getColor(Variables.context, R.color.orange));
} else {
bidLayouts.setBackgroundColor(ContextCompat.getColor(Variables.context, R.color.White));
}
if (autoBidMode == Setting.AUTO_BID_MODE_CHEAPEST) {
for (TDriverBids rgxBids2 : rgxBidOffer) {
if (rgxBids2.amICheapest) {
autoBid = rgxBidOffer.get(Integer.parseInt(v.getTag().toString()));
BidDriverPrice.setBackgroundColor(getResources().getColor(R.color.Chartreuse));
} else {
BidDriverPrice.setBackgroundColor(getResources().getColor(android.R.color.transparent));
}
}
} else if (autoBidMode == Setting.AUTO_BID_MODE_NEAREST) {
for (TDriverBids rgxBids2 : rgxBidOffer) {
if (rgxBids2.amINearest) {
autoBid = rgxBidOffer.get(Integer.parseInt(v.getTag().toString()));
BidDriverMins.setBackgroundColor(getResources().getColor(R.color.Chartreuse));
} else {
BidDriverMins.setBackgroundColor(getResources().getColor(android.R.color.transparent));
}
}
}
}
}
레이아웃 xml에서 배경색을 변경하면 효과가 있습니까? – muratgu
'getResources(). getColor (android.R.color.red)'와 같은 다른 색상으로 시도해보십시오. –
android.R.color.holo_red_dark를 사용해 보았습니다. 여전히 작동하지 않습니다. - 좋은 제안! – apmartin1991