Q:

How restart Fragment in my Activity - Android

I have an activity that have 3 fragment inside. I need restart a first fragment in my activity with click on Button.
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(new HomeFragment(), "Home");
adapter.addFrag(new CategoryFragment(), "Category");
adapter.addFrag(new FilterFragment(), "Filter");
viewPager.setAdapter(adapter);

I test the following way but doesn't work and show error:
refresh fragment at reload
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.Fragment.setNextAnim(int)' on a null object reference 

A:

You can reload your fragment with this:
FragmentTransaction tr = getFragmentManager().beginTransaction();
tr.replace(R.id.fragment_layout, instanceFragment);
tr.commit()

Being instanceFragment the instance of the fragment you wanna to reload and fragment_layout the FrameLayout component in your activity layout XML file.

