Das ist mein xml:SwipeRefreshLayout funktioniert nicht mehr, wenn ich Tätigkeit zu ändern, und dann kommen Sie wieder
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_below="@id/id_bar"
android:layout_marginBottom="0.5dp"
android:background="@color/blue"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:dividerHeight="0dp"
android:layout_gravity="top"
android:divider="@null"
android:background="@color/yellow"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.bartoszlipinski.recyclerviewheader2.RecyclerViewHeader
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="70dp"
android:visibility="gone"
android:layout_gravity="center_horizontal|top">
<include
android:id="@+id/header_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_top_green"
layout="@layout/header_profile"/>
</com.bartoszlipinski.recyclerviewheader2.RecyclerViewHeader>
<RelativeLayout
android:id="@+id/placeholderContainer"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:layout_height="match_parent">
<ImageView
android:id="@+id/placeholderPic"
android:layout_alignParentTop="true"
android:layout_marginTop="100dp"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pin_newtrips"/>
<TextView
android:id="@+id/placeholderText"
android:layout_below="@id/placeholderPic"
android:padding="10dp"
android:textSize="28dp"
android:textColor="@color/gray32"
android:text="@string/home.status.heading.setup"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/placeholderAddItems"
android:layout_marginTop="10dp"
android:layout_below="@id/placeholderText"
android:layout_width="match_parent"
android:layout_height="wrap_content"></RelativeLayout>
</RelativeLayout>
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
ich es über butter initiieren:
@InjectView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
Das ist mein refreshListener:
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// Refresh items
if(timeLineAdapter!= null)
timeLineAdapter.setLastAnimatedPosition(0);
refresh(false);
}
});
Ich nenne dies onResume, so dass es funktioniert, wenn ich darauf zurückkomme. Jetzt funktioniert es zunächst, wenn ich die Home-Taste drücke und zurückkomme, klappt es. Wenn ich meine Aktivität zu einer anderen ändere und dann zurückkomme, funktioniert sie nicht mehr. Wie kann das behoben werden?
EDIT:. Wie Sie sehen können, das Haupt Kind des SwipeRefreshLayout ist ein FrameLayout die die RecyclerView enthält, mein RecyclerViewHeader und einen Platzhalter für die Liste (hier, führen auf den Platzhalter unten wischen sollte auch auffrischen Swipe Ich habe zwischen diesen 2 Ansichten, eine ScrollView, und jetzt die Streichen, um zu aktualisieren funktioniert. ABER, mit der recyclerview in der Scrollview ruiniert meine RecyclerView. Ich kann nach unten scrollen, aber nicht up. Alle anderen Ideen?