title: Android: Getting white screen with fragment transaction
body: <p>I am making a news app where I have a fragment that holds all the news in a list and another fragment that have videos list. When you touch a new it will call a method from the activity named openNewsCont that will replace the current fragment with another one.</p>
  
  <p>The proble I am having is when I call that method I get a blank screen, I have looked many other codes but I couldn't find the solution for my problem.</p>
  
  <p>Here is the method I call from the MainActivity.java</p>
  
  <pre class="lang-js prettyprint-override"><code>public void openNewsCont(String text) {
  
      android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
      android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
      ft.replace(R.id.pager, new NewsContent() );
      ft.addToBackStack(null);
      ft.commit();
      fm.executePendingTransactions();
   }
  </code></pre>
  
  <p>Here is the Tab1.java that hold the news and calls the method from the MainActivity.java</p>
  
  <pre class="lang-js prettyprint-override"><code>package com.example.link_test;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.LinearLayout;
  
      public class Tab1 extends Fragment {
  
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {
  
                final View android = inflater.inflate(R.layout.tab1, container, false);             
                LinearLayout newLink = (LinearLayout) android.findViewById(R.id.news1);
                newLink.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      String text = "Text from fragment";
                      MainActivity ma = (MainActivity) getActivity();
                      ma.openNewsCont(text);
                  }
                  });
  
                return android;
      } 
  }
  </code></pre>
  
  <p>And here is the fragment that should be called and shows a blank screen NewsContent.java</p>
  
  <pre><code>package com.example.link_test;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class NewsContent extends Fragment {
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
              View view = inflater.inflate(R.layout.news_content, container, false);
              return view;
      }
  }
  </code></pre>