In the first time that I change the visibility of the fragments in my app, the fragment showed isn`t the fragment that I set to show.
My layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<fragment
android:id="@+id/act_main_frag_top_bar"
class="br.com.myapp.fragments.TopBarFragment"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<fragment
android:id="@+id/act_main_frag_toolbar"
class="br.com.myapp.fragments.ToolbarFragment"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<!-- Tabs -->
<fragment
android:id="@+id/act_main_frag_twitter"
class="br.com.myapp.fragments.TwitterFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"/>
<fragment
android:id="@+id/act_main_frag_facebook"
class="br.com.myapp.fragments.FacebookFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"/>
<fragment
android:id="@+id/act_main_frag_tv_show"
class="br.com.myapp.fragments.TVShowFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"/>
<fragment
android:id="@+id/act_main_frag_info"
class="br.com.bluepen.mixtv.fragments.InfoFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"/>
<fragment
android:id="@+id/act_main_frag_streaming"
class="br.com.myapp.fragments.StreamingFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"/>
</LinearLayout>
And myActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager manager = getSupportFragmentManager();
mStreamingFrag = (StreamingFragment) manager.findFragmentById(R.id.act_main_frag_streaming);
mFacebookFrag = (FacebookFragment) manager.findFragmentById(R.id.act_main_frag_facebook);
mTwitterFrag = (TwitterFragment) manager.findFragmentById(R.id.act_main_frag_twitter);
mTVShowFrag = (TVShowFragment) manager.findFragmentById(R.id.act_main_frag_tv_show);
mInfoFrag = (InfoFragment) manager.findFragmentById(R.id.act_main_frag_info);
mToolbar = (ToolbarFragment) manager.findFragmentById(R.id.act_main_frag_toolbar);
mToolbar.setListener(this);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.show(mStreamingFrag);
transaction.commit();
}
After the onCreate, the fragment getting showed is the TwitterFragment, and not the StreamingFragment that I set to show in the final of the onCreate method.