Android Remove Fragments
<p>How do you detach or remove FragmentTransaction? Can anyone show me an example on how to detach it. I've tried detach and remove. Its still not working. Please help me. Note that I'm using asynctask in my codes. </p>

<pre><code>    @Override
        public void onActivityCreated(Bundle savedInstanceState) {

                new loadListView().execute();

            super.onActivityCreated(savedInstanceState);
        }

        public class loadListView extends AsyncTask&lt;Integer, String, String&gt; {

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
            }

            @Override
            protected String doInBackground(Integer... args) {
                ............
                }   


            @Override
            protected void onPostExecute(String args) {

                if (getActivity() != null) {
                adapter=new MainPageLazyAdapter(getActivity(), menuItems);
                setListAdapter(adapter);



             }
        }


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



    FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(android.R.id.content, this);
        fragmentTransaction.attach(this);
        fragmentTransaction.commit();
    }

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

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.detach(this);
        fragmentTransaction.commit();



    }

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

    }


}
</code></pre>

<p>LOGCAT :</p>

<pre><code>10-09 14:49:42.305: E/AndroidRuntime(5731): FATAL EXCEPTION: main
10-09 14:49:42.305: E/AndroidRuntime(5731): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.actionbarsherlocknavtab/in.wptrafficanalyzer.actionbarsherlocknavtab.MainActivity}: java.lang.NullPointerException
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.os.Looper.loop(Looper.java:137)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread.main(ActivityThread.java:4512)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:982)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at dalvik.system.NativeStart.main(Native Method)
10-09 14:49:42.305: E/AndroidRuntime(5731): Caused by: java.lang.NullPointerException
10-09 14:49:42.305: E/AndroidRuntime(5731):     at in.wptrafficanalyzer.actionbarsherlocknavtab.AndroidFragment.onTabSelected(AndroidFragment.java:170)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.actionbarsherlock.internal.app.ActionBarWrapper$TabWrapper.onTabSelected(ActionBarWrapper.java:344)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.android.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:512)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.android.internal.app.ActionBarImpl.addTab(ActionBarImpl.java:441)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.android.internal.app.ActionBarImpl.addTab(ActionBarImpl.java:427)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at com.actionbarsherlock.internal.app.ActionBarWrapper.addTab(ActionBarWrapper.java:377)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at in.wptrafficanalyzer.actionbarsherlocknavtab.MainActivity.onCreate(MainActivity.java:24)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.Activity.performCreate(Activity.java:4465)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
10-09 14:49:42.305: E/AndroidRuntime(5731):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
10-09 14:49:42.305: E/AndroidRuntime(5731):     ... 11 more
</code></pre>
