こんにちは私は2つのフラグメントを含むlinearLayoutを持っており、このレイアウトにコード付きのタブを追加します。私が欲しいのは、tab1をクリックすると、指示されたクラスからそれ自身を断片化することは大丈夫ですが、tab2ではこのクラスを別のクラスに変更したいと思います。 <FrameLayout/>
フラグメントのクラスを動的に変更する方法
<FrameLayout
android:id="@+id/frag_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_width="@dimen/titles_size"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/frag_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
にXMLレイアウトであなたに
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frags">
<fragment class="com.tugce.MitsActionBar.DoktorlarFragment"
android:id="@+id/frag_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_width="@dimen/titles_size"
android:layout_height="match_parent" />
<fragment class="com.tugce.MitsActionBar.ContentFragment"
android:id="@+id/frag_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
は、私は単に私のフラグメント= DoktorlarFragmentとでframeLayoutを置き換えるあなたの答えをありがとう()エラーも画面にも何も表示されません。 – tugce