I have a ViewPager where one of its belonging fragments has its own ActionBar item, so that when you slide to that page the item comes forth in the ActionBar, slide to another page the item goes away.
I would like this to happen with a fade-in/fade-out animation - but don't know how.
I've tried the following. But it gives me a NullPointerExecption on itemView.startAnimation(fade_in);
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.intruders_list, menu);
// Setup animation
Animation fade_in = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
fade_in.setInterpolator(new AccelerateInterpolator());
fade_in.setDuration(250);
// Animate
MenuItem deleteItem = menu.findItem(R.id.action_delete);
View itemView = deleteItem.getActionView();
itemView.startAnimation(fade_in); // NPE HERE
super.onCreateOptionsMenu(menu, inflater);
}