Q:

Android Application closing unexpectedly while tabbed fragments swipe

i have a fragment activity which contains three fragments 
1) DayFragment 
2) WeekFragment 
3) MonthFragment
when i swipe the first fragment application getting closed and giving the exception 
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953)
RepeatRemainderFragmentActivity.java is my fragment activity
public class RepeatRemainderFragmentActivity extends FragmentActivity implements
        ActionBar.TabListener {

    private ViewPager viewPager;
    private TabsPagerAdapter mAdapter;
    private ActionBar actionBar;
    // Tab titles
    private String[] tabs = { "Day", "Week", "Month" };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_repeat_fragment);

        // Initilization
        viewPager = (ViewPager) findViewById(R.id.pager);
        actionBar = getActionBar();
        mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

        viewPager.setAdapter(mAdapter);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);        

        // Adding Tabs
        for (String tab_name : tabs) {
            actionBar.addTab(actionBar.newTab().setText(tab_name)
                    .setTabListener(this));
        }

        /**
         * on swiping the viewpager make respective tab selected
         * */
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {
                // on changing the page
                // make respected tab selected
                actionBar.setSelectedNavigationItem(position);
            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
            }
        });
    }

    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft) {
    }

    @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
        // on tab selected
        // show respected fragment view
        viewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    }

}

Dayfragment.java
public class DayFragment extends Fragment implements OnClickListener, OnItemSelectedListener{

    private View rootView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        rootView = inflater.inflate(R.layout.fragment_day, container, false);

        InitializeUI();
        setListeners();
        setCurrentDate();
        dayRepeatSpinner();

        return rootView;
    }

    private void setCurrentDate() {
        // TODO Auto-generated method stub

            Calendar c = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            String formattedDate = df.format(c.getTime());
            day_startsOn_tv.setText(formattedDate);
    }
    .
    .
    .

WeekFragment.java
public class WeekFragment extends Fragment implements OnClickListener, OnItemSelectedListener{

    private View rootView;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        rootView = inflater.inflate(R.layout.fragment_week, container, false);

        InitializeUI();
        setListeners();
        setCurrentDate();
        weekRepeatSpinner();

        return rootView;
    }

    private void setCurrentDate() {
        // TODO Auto-generated method stub

            Calendar c = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            String formattedDate = df.format(c.getTime());
            week_startsOn_tv.setText(formattedDate);

    }

    private void setListeners() {
        // TODO Auto-generated method stub
        week_startsOn_rl.setOnClickListener(this);
        week_repeatEvery_rl.setOnClickListener(this);
        week_ends_rl.setOnClickListener(this);
        weekSpinner.setOnItemSelectedListener(this);
        sun_tv.setOnClickListener(this);
        mon_tv.setOnClickListener(this);
        tue_tv.setOnClickListener(this);
        wed_tv.setOnClickListener(this);
        thu_tv.setOnClickListener(this);
        fri_tv.setOnClickListener(this);
        sat_tv.setOnClickListener(this);
    }

    .
    .
    .

MonthFragment.java 
public class MonthFragment extends Fragment implements OnClickListener, OnItemSelectedListener{

    private View rootView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        rootView = inflater.inflate(R.layout.fragment_month, container, false);

        InitializeUI();
        setListeners();
        setCurrentDate();
        monthRepeatSpinner();

        return rootView;
    }

    private void setCurrentDate() {
        // TODO Auto-generated method stub

            Calendar c = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            String formattedDate = df.format(c.getTime());
            month_startsOn_tv.setText(formattedDate);// showing exception inthis line

    }

    private void setListeners() {
        // TODO Auto-generated method stub
        month_startsOn_rl.setOnClickListener(this);
        month_repeatEvery_rl.setOnClickListener(this);
        month_repearBy_rl.setOnClickListener(this);
        month_ends_rl.setOnClickListener(this);
        monthSpinner.setOnItemSelectedListener(this);
    }

private void InitializeUI() {
  // TODO Auto-generated method stub
    month_startsOn_rl = (RelativeLayout) rootView.findViewById(R.id.month_startOn_relativeLayout);
    month_repeatEvery_rl = (RelativeLayout) rootView.findViewById(R.id.month_repeat_relativeLayout);
    month_repearBy_rl = (RelativeLayout) rootView.findViewById(R.id.month_repeatBy_relativeLayout);
    month_ends_rl = (RelativeLayout) rootView.findViewById(R.id.month_ends_relativeLayout);

    monthSpinner = (Spinner) rootView.findViewById(R.id.month_spinner);

}

following is my logcat
04-29 02:27:14.366: E/AndroidRuntime(1499): FATAL EXCEPTION: main
04-29 02:27:14.366: E/AndroidRuntime(1499): Process: com.ielts.notes, PID: 1499
04-29 02:27:14.366: E/AndroidRuntime(1499): java.lang.NullPointerException
04-29 02:27:14.366: E/AndroidRuntime(1499):     at com.ielts.notes.tabswipe.MonthFragment.setCurrentDate(MonthFragment.java:54)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at com.ielts.notes.tabswipe.MonthFragment.onCreateView(MonthFragment.java:42)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:488)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.support.v4.view.ViewPager$3.run(ViewPager.java:249)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.view.Choreographer.doFrame(Choreographer.java:543)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.os.Handler.handleCallback(Handler.java:733)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.os.Handler.dispatchMessage(Handler.java:95)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.os.Looper.loop(Looper.java:136)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at java.lang.reflect.Method.invokeNative(Native Method)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at java.lang.reflect.Method.invoke(Method.java:515)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-29 02:27:14.366: E/AndroidRuntime(1499):     at dalvik.system.NativeStart.main(Native Method)

A:

Where is month_startsOn_tv defined? I think that the error is that something like
TextView month_startsOn_tv = (TextView)findViewById(R.id.month_startsOn_tv);

is missing, because the error message is for null element, and when this textView is not defined it is null and you can't set its text.
To use it from everywhere, you should initialize it at the top like your private View rootView; with private TextView month_startsOn_tv;

