こんにちは、私は私がなぜは、フラグメントをロードすることはできません
FragmentManager manager = getFragmentManager();
FragmentTransaction trans = manager.beginTransaction();
trans.replace(R.id.containerr,new FragmentLastComments());
trans.commit();
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/containerr"
android:layoutDirection="ltr">
</RelativeLayout>
フラグメントXML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="55dp"
android:orientation="vertical">
<TextView
android:id="@+id/txt_lastcomments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="20dp"
android:layout_marginBottom="10dp"
android:text="last comments" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:id="@+id/rv_lastcomments"/>
</LinearLayout>
</RelativeLayout>
この行は動作していない
を知らないこの行の問題を抱えていますtrans.replace(R.id.containerr,new FragmentLastComments());
私は、この行私は何の問題が届かないが、私は、私は問題を取得しています。この行を使用していたときを削除すると、私はここに
R.id.containerr
を問題だと思い、私は誰かがこれを解決するために私を助けることを願っています
:
そして、これを使用してフラグメントの方法を変更しますか? – Raghavendra
解決策を試すhttps://stackoverflow.com/questions/14810348/android-fragment-replace-doesnt-replace-content-puts-it-on-top – Raghavendra
https://i.stack.imgur.com/avPHl。 png – ShWaEkI