android - Fragment is added to activity and fragments oncreateview is called but view is not being inflated? -
i have activity extends appcompatactivity , i'm adding fragment in framelayout inside activity.the fragments oncreateview being called fragments view not being inflated or shown.
appcompat activity's layout:
<framelayout 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:background="#fff" > <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/contain"> </framelayout> </framelayout>
i'm adding fragment child framelayout.the code attach fragment below:
onefragment m = new onefragment(); android.support.v4.app.fragmentmanager fm = getsupportfragmentmanager(); android.support.v4.app.fragmenttransaction ft = fm.begintransaction(); ft.add(r.id.contain,m); ft.addtobackstack(null); ft.commit();
this code inside oncreateview of onefragment:
view view = inflater.inflate(r.layout.fragment_one, container, false); //find +1 button mplusonebutton = (plusonebutton) view.findviewbyid(r.id.plus_one_button); return view;
fragment_one.xml:
<framelayout 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" tools:context=".onefragment"> <com.google.android.gms.plus.plusonebutton xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" android:id="@+id/plus_one_button" android:layout_width="wrap_content" android:layout_height="wrap_content" plus:size="standard" plus:annotation="inline" /> <button android:layout_width="match_parent" android:layout_height="wrap_content" /> </framelayout>
Comments
Post a Comment