2014-04-28 3 views
0

제목에서 알 수 있듯이 Xperia 휴대 전화의 CheckboxBackground에 문제가 있습니다. 코드는 모든 장치에서 잘 작동하지만 Xperia에서는 문제가 없습니다. 단순히 배경을 보여주지 않습니다.Xperia의 확인란 문제 배경

myCheckbox.setBackgroundResource(R.drawable.customBackground); 

어느 this other post on SO에 명시된 바와 같이 myCheckbox.setBackgroundColor(Color.RED);

을 수행, Background 방법은 엑스 페리아에 깨진 것 같다. 주어진 픽스를 시도했는데 색상에 잘 맞습니다.

myCheckbox.setDrawingCacheEnabled(true); 
myCheckbox.setDrawingCacheBackgroundColor(Color.RED); 

문제는 나를위한 setDrawingCacheBackgroundResource(int) 방법입니다.

1 누군가가 그것을 해결하는 방법을 알고 있나요 :

는 따라서 내 두 가지 질문이 있습니다?

2- 누군가가 알고있는 경우 전화가 실제로 Xperia인지 어떻게 알 수 있습니까? 그냥 뭔가를 할

if(/*phone is Xperia*/) 
    /*Use fix*/ 
else 
    /*Proceed normaly*/ 

고마워!

답변

0

나는이 시도하지만 난 만족하지 찾을 :

myCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() 
{ 
    @Override 
    public void onCheckedChanged(CompoundButton checkbox, boolean checked) 
    { 
     layout_checkboxsubstitute.setBackgroundResource(checked ? R.drawable.customBackgroundStateOn : R.drawable.customBackgroundStateOff); 
    } 
}); 

내가 만든 Layout이고 Checkbox 대신 표시하십시오. 수동으로 Background을 변경해야합니다. 차라리 더 편한 myCheckbox.setBackgroundResource(R.drawable.customBackground);으로 머물러야합니다.

누군가 더 좋은 해결책이 있습니까?

0

setBackgroundColor()에 대해 xperia에 몇 가지 문제가 있습니다. setDrawingCacheBackgroundColor()와 함께 작동합니다. 당신이 전화 제조 업체 및 당신이 그것을 사용하여 얻을 수있는 모델을 얻으려면 경우

CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox1); 
checkBox.setDrawingCacheEnabled(true); 
checkBox.setDrawingCacheBackgroundColor(Color.RED); 

,

String manufacturer = Build.MANUFACTURER; 
String model = Build.MODEL; 
+0

나는 이미 이것을했지만, 명시된 바와 같이 BackgroundColor를 변경하고 싶지는 않지만'setDrawingCacheBackgroundResource (int)'메소드가 필요할 것이다. –

+0

이것이 xperia의 문제입니다. 대신 checkbox를 버튼이나 다른 배경으로 대체하여 체크/눌렀는지 여부를 나타낼 수 있습니다. –