Your problem lies with assigning your tweenAnimation
field
Animation tweenAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.tween1);
getActivity()
is null at this point in your fragments lifecycle (creation) and will cause loadAnimation
to fail or return a null animation. Accessing this will then result in a NPE (if loadAnimation
hasn't already thrown one)
Move assigning tweenAnimation
to a point in the fragment's lifecycle where the activity will exist like onCreate
ex.
Animation tweenAnimation;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreat(savedInstanceState);
tweenAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.tween1);
}