title: Moving from activity to fragment-NullPointer exception in onCreateView
body: <p>My project crashes and shows following error on switching to fragment from activity.</p>
  
  <pre><code>08-12 20:00:56.835    1711-1711/com.facebooklogin E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.NullPointerException
              at info.fastbadmainton2.slidingmenu.NewsFragment.onCreateView(NewsFragment.java:66)
              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
              at android.app.BackStackRecord.run(BackStackRecord.java:635)
              at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
              at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
              at android.os.Handler.handleCallback(Handler.java:615)
              at android.os.Handler.dispatchMessage(Handler.java:92)
              at android.os.Looper.loop(Looper.java:153)
              at android.app.ActivityThread.main(ActivityThread.java:5086)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>It shows error in the statement-</p>
  
  <pre><code>actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
  </code></pre>
  
  <p>Why it shows error in this statement?My app doesn't crashes if i remove this statement but my fragment becomes transparent such that activity is visible behind.Why my fragment becoms transparent?</p>
  
  <p>Activity</p>
  
  <pre><code>public class NewsPopup extends FragmentActivity {
      TextView tv1,tv2,tv3;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.newspopup);
          Configuration config = getResources().getConfiguration();
  
          FragmentManager fragmentManager = getFragmentManager();
          final FragmentTransaction fragmentTransaction =
                  fragmentManager.beginTransaction();
  
          tv1=(TextView)findViewById(R.id.textView21);
          tv1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Fragment newFragment = new NewsFragment();
                  fragmentTransaction.replace(android.R.id.content, newFragment);
                  fragmentTransaction.commit();
              }
          });
          tv2=(TextView)findViewById(R.id.textView22);
          tv2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent();
                  i.setClass(getApplicationContext(), NewsPopup2.class);
                  startActivity(i);
              }
          });
          tv3=(TextView)findViewById(R.id.textView24);
          tv3.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent();
                  i.setClass(getApplicationContext(), NewsPopup3.class);
                  startActivity(i);
              }
          });
  
      }
  }
  </code></pre>
  
  <p>Fragment</p>
  
  <pre><code>public class NewsFragment extends Fragment   {
      private FragmentActivity myContext;
      private ViewPager viewPager;
      private TabsPagerAdapter2 mAdapter;
      ActionBar actionBar;
       private String[] tabs = { "My Teams", "All Teams", "Trending" };
      public NewsFragment(){}
      @Override
      public void onAttach(Activity activity) {
          myContext=(FragmentActivity) activity;
          super.onAttach(activity);
      }
  
  
      public void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setHasOptionsMenu(true);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.news, container, false);
  
  
          actionBar = getActivity().getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
          TextView tv=(TextView)rootView.findViewById(R.id.textView11);
  
          tv.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent();
                  i.setClass(myContext, NewsPopup.class);
                  startActivity(i);
              }
          });
  
          TextView tv1=(TextView)rootView.findViewById(R.id.textView13);
  
          tv1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent();
                  i.setClass(myContext, NewsPopup2.class);
                  startActivity(i);
              }
          });
  
          TextView tv2=(TextView)rootView.findViewById(R.id.textView43);
  
          tv2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent();
                  i.setClass(myContext, NewsPopup3.class);
                  startActivity(i);
              }
          });
          return rootView;
      }
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle item selection
          switch (item.getItemId()) {
              case R.id.action_search2:
                  // recordVideo();
                  //countClick++;
                  Intent i = new Intent();
                  i.setClass(myContext, LeagueSelect2.class);
                  startActivity(i);
                  return true;
  
              default:
                  return super.onOptionsItemSelected(item);
          }
      }
      /*@Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
          viewPager.setCurrentItem(tab.getPosition());
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }*/
  }
  </code></pre>