如何破坏视图寻呼机片段Android的子片段中的视图或异步调用

时间:2018-01-11 05:10:21

标签: android android-fragments memory-leaks android-viewpager child-fragment

我在 ViewPager 中有两个片段,而在第一个中我添加了两个子片段这两个子片段中包含视图和异步调用。现在,当我从viewPager的一个片段滑动到另一个片段然后返回第一个片段时,所有视图都保留在子片段中。

我想要儿童片段'从viewpager的第一个片段向另一个片段滑动到避免内存泄漏时,视图和异步调用为null或被销毁。一切都很好。

我在第一个视图分页器片段中添加了两个片段,如下所示:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.strongholdapps.scannertr.tablayout.Fragments.FirstFragment">

<fragment
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:name="com.strongholdapps.scannertr.tablayout.Fragments.FirstCurrencyFragment"
    android:id="@+id/firstCurrency"/>

<fragment
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:name="com.strongholdapps.scannertr.tablayout.Fragments.FirstCurrencyFragment"
    android:id="@+id/secondCurrency"/>
</LinearLayout>

0 个答案:

没有答案