android - cannot load fragment -
hi have problem in line not know why
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> fragment 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> this line not working
trans.replace(r.id.containerr,new fragmentlastcomments()); when remove line i'm not getting problem when i'm using line i'm getting problem think problem here
r.id.containerr i hope me solve this
try way,
fragmentmanager mfragmentmanager=getfragmentmanager(); fragment mfragment = new fragmentlastcomments(); mfragmentmanager .begintransaction() .replace(r.id.rl_main_new, fragmentdash, "tag") .commit(); i hope helps you.
Comments
Post a Comment