Closed anonym24 closed 7 years ago
Oh I found the problem, I commented in xml one of my preference (SeekBarPreference one) but I didn't remove code in my preference fragment:
SeekBarPreference seekBarPreference = (SeekBarPreference) findPreference("myseekbar");
and it just broke everything. interesting that app doesn't crash if it can't find the preference, it just breaks everything and doesn't execute some code in onCreatePreferencesFix
method.
really hard to debug app)
so now findPreference("test").setIcon(getDrawable(R.drawable.test));
seems to be working again
also interesting that
SwitchPreferenceCompat test = (SwitchPreferenceCompat) findPreference("test");
test.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.test));
doesn't work, and code after these lines also aren't being executed.
Google shocks me)
Instead of
android:icon="@drawable/test"
I tried this:findPreference("test").setIcon(getDrawable(R.drawable.test))
and it was working, it even was working with Vector Drawable (.xml images) because adding vector drawable in xml didn't work:
app:srcCompat="@drawable/test" (for .xml images)
only this method (programmatically) helped me to set vector drawable for a preference
But when I later run my app and opened the settings, icons weren't there anymore. I tried to build my project again and now it just doesn't want to work, only works with xml
android:icon="@drawable/test"
. I don't really get what is going on)So now
setIcon
method doesn't even work with ordinary png image for me:What could be a problem?