How can I refresh my fragment (chart-fragment) in parent fragment?
I tried doing it like this, but it doesn't work.
Java (refresh method):
Fragment fragment = getChildFragmentManager().findFragmentById(R.id.statistic_order_fragment);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.detach(fragment);
fragmentTransaction.attach(fragment);
fragmentTransaction.commit();
XML:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<fragment
android:id="@+id/statistic_order_fragment"
android:tag="ORDER"
android:name="com.readyscript.dk.storemanagement.Statistic.StatisticOrderFragment"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
card_view:layout="@layout/fragment_statistic_order" />
<fragment
android:id="@+id/statistic_sum_fragment"
android:tag="SUM"
android:name="com.readyscript.dk.storemanagement.Statistic.StatisticSumFragment"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
card_view:layout="@layout/fragment_statistic_sum" />
<fragment
android:id="@+id/statistic_check_fragment"
android:tag="CHECK"
android:name="com.readyscript.dk.storemanagement.Statistic.StatisticCheckFragment"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
card_view:layout="@layout/fragment_statistic_check" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
When I use SwipeRefreshLayout, I need to refresh all the 3 Fragments without restarting the parent Fragment.