Lorsque le commutateur fragment avec SwipeRefreshLayout pendant rafraîchissant, le fragment se fige mais, en réalité, encore du travail

Mise à JOUR: j'ai pensé qu'il fonctionnait correctement. Mais après quelques test de la difficulté existe toujours *sniff*

Puis j'ai fait une version plus simple de voir ce qui exactement se passer et je sais que le rafraîchissant fragment qui doit avoir été détaché reste là. Ou exactement, le point de vue de l'ancien fragment de gauche il y, sur le dessus de le plus récent fragment. Depuis RecyclerView du fond de mon application d'origine n'est pas transparent, donc Il s'est avéré que j'ai dit avant.

FIN DE LA MISE À JOUR


J'ai un MainActivity avec mise en page comme ceci:

<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>

Le fragment ContentView je utiliser pour remplir @id/container est configuré comme:

<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>

Et voici onCreateView() de ContentView

@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;
}

Puis dans MainActivity je changer le contenu à afficher par commutation différents ContentView. Tout a l'air bon, sauf une chose: lorsque je change de ContentView fragments PENDANT rafraîchissante tiroir de navigation, contenu gèle. Mais en fait toutes les choses fonctionnent comme d'habitude, sauf que vous ne pouvez pas le voir.

  • Normal, vous voulez vous rafraîchir, & tandis que vous changez l'ensemble de la liste, puis lors de l'actualisation est de mettre fin, c'essayez de recharger les données qui ont changé. Vous devez verrouiller la glisser lors de l'actualisation.
  • Eh bien, il semble que Google est la faute de... Après la mise à AppCompat v21.0.2, toute douleur a disparu XD. Merci <3
InformationsquelleAutor zlm2012 | 2014-11-21