title: passing context to fragment
body: <p>well i am doing a small android project involving fragments.. my log cat is showing null pointer exception as context value is null.. </p>
  
  <p>this is my code </p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.syllabusselection, container, false);
      main(rootView);
      return rootView;
  }
  public void main(View rootView)
   {
       TextView textyear,textsubject,textschema,textPowered ;
          final Context context = getActivity();
          Typeface Roboto = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto/Roboto-Light.ttf");
          Typeface Nexa = Typeface.createFromAsset(context.getAssets(),"fonts/nexa/Nexa_Light.ttf");//Nexa_Light.ttf Nexa_Bold.ttf
  
  
          textsubject = (TextView)rootView.findViewById(R.id.textsubject);
          textschema = (TextView)rootView.findViewById(R.id.textscheme);
          textPowered = (TextView)rootView.findViewById(R.id.textPowered);
  </code></pre>
  
  <p>well originally the </p>
  
  <p>final Context context = getActivity();</p>
  
  <p>was null i changed it to getActivity() but still i am getting null pointer excewption.. so what is the errror?? </p>
  
  <p>this is my log cat </p>
  
  <pre><code>03-10 03:30:06.015: E/AndroidRuntime(1218): FATAL EXCEPTION: main
  03-10 03:30:06.015: E/AndroidRuntime(1218): Process: info.androidhive.tabsswipe, PID: 1218
  03-10 03:30:06.015: E/AndroidRuntime(1218): java.lang.NullPointerException
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at info.androidhive.tabsswipe.Question.main(Question.java:63)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at info.androidhive.tabsswipe.Question.onCreateView(Question.java:55)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.View.measure(View.java:16497)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.View.measure(View.java:16497)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.View.measure(View.java:16497)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.View.measure(View.java:16497)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.Choreographer.doFrame(Choreographer.java:544)
  03-10 03:30:06.015: E/AndroidRuntime(1218):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
  </code></pre>