vendredi 22 mai 2015

CheckBox with setColorFilter changes his graphical state when starts new intent(dialog)

I have a dialog with 1 Button and 2 Checkboxes, for each I set color filter like that:

int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable",
        "android");
Drawable drawable = getActivity().getResources().getDrawable(id);
drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
checkBox1.setButtonDrawable(drawable);
checkBox2.setButtonDrawable(drawable);        

when FragmentDialog shows CheckBoxes are selected, but they checked state is false. My button have onClickListener:

Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri)null);
getActivity().startActivityForResult(intent, 5);                

and when I press that button my CheckBoxes again changes state to selected no matter what checked state is.

Is there any solution to solve that state changes?

Aucun commentaire:

Enregistrer un commentaire