I\'ve made a SwitchPreference for my app\'s preferences.
The problem is that the SwitchPreference is not showing animation whe
I noticed that a few different things could cause the animation to go missing for my SwitchPreference objects:
if the SwitchPreference is the very first Preference in the settings activity.
if I extend the SwitchPreference and use that instead (post describing a similar problem).
To avoid the first problem, I created a DummyPreference class which I used as the first Preference in the PreferenceScreen instead. Examples below.
DummyPreference.java
public class DummyPreference extends Preference
{
public DummyPreference(Context context,AttributeSet attrs)
{
super(context,attrs);
}
@Override
public View getView(View convertView,ViewGroup parent)
{
View v = new View(getContext());
v.setVisibility(View.GONE);
return v;
}
}
pref_whatever.xml
To avoid the second problem, I had to just resort to using android's plain old Preference classes in the XML, and I moved any extra logic needed into the Activity or Fragment containing the Preference objects.
I know this is an old post. I'm just hoping that it may help someone else in the future.