Wenn das Fragment mit SwipeRefreshLayout während des Aktualisierens gewechselt wird, friert das Fragment ein, funktioniert aber tatsächlich noch.

UPDATE: Ich dachte, es funktioniert richtig. Aber nach ein paar Tests gibt es immer noch Probleme * sniff *

Dann habe ich eine einfachere Version gemacht, um zu sehen, was genau passiert, und ich erfahre, dass das erfrischende Fragment, das hätte abgetrennt werden sollen, immer noch da ist. Oder genau, der Blick auf das alte Fragment dort links,au das neuere Fragment. Da der Hintergrund meiner ursprünglichen App in RecyclerView nicht transparent ist, hat sich herausgestellt, was ich zuvor gesagt habe.

END OF UPDATE

Ich habe einMainActivity mit Layout wie diesem:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout android:id="@+id/container" android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         If you're not building against API 17 or higher, use
         android:layout_gravity="left" instead. -->
    <!-- The drawer is given a fixed width in dp and extends the full height of
         the container. -->
    <fragment android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent"
        android:layout_gravity="start" tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

as FragmeContentView Ich benutze zu füllen@id/container ist konfiguriert als:

<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/tweet_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_300"/>

</android.support.v4.widget.SwipeRefreshLayout>

nd hier istonCreateView() vonContentView

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View inflatedView = inflater.inflate(R.layout.fragment_content, container, false);

    mRecyclerView = (RecyclerView) inflatedView.findViewById(R.id.tweet_list);
    mRecyclerView.setHasFixedSize(false);

    mLinearLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
    mRecyclerView.setLayoutManager(mLinearLayoutManager);

    mTweetList = new ArrayList<Tweet>;
    mAdapter = new TweetAdapter(mTweetList);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mSwipeRefreshLayout = (SwipeRefreshLayout) inflatedView.findViewById(R.id.contentView);
    mSwipeRefreshLayout.setOnRefreshListener(
        ...
    );
    return inflatedView;
}

Dann inMainActivity Ich schalte den angezeigten Inhalt um, indem ich denContentView. Alles sieht gut aus bis auf eine Sache: wenn ich @ wechsContentView Fragmente WÄHREND der Aktualisierung durch die Navigationsleiste friert der Inhalt ein. Aber eigentlich funktionieren alle Dinge wie gewohnt, außer Sie können es nicht sehen.

Antworten auf die Frage(16)

Ihre Antwort auf die Frage