2016-05-31 102 views
0

我有一個ListView和一個SwipeRefreshLayout。一切工作正常,我可以向上/向下滾動,並在清單的頂部刷新工作。 但是,如果我從列表視圖中選擇一個項目,我的應用程序會顯示另一個片段。之後,我想返回到列表視圖而不滾動到頂部。 我解決了這個保存/恢復列表視圖狀態,但如果我不會等待1-2秒後,我回到列表視圖,我想向上滾動刷卡刷新顯示,但不滾動。 如果在我向上滾動之前等一會兒,一切都會好的。 在Android 4.4.2上沒有問題。在Android 5.0.2和6.0.0上它的問題。Android ListView和刷卡刷新

+0

使用您的列表視圖片段從片段管理器backstack中彈出。並正確處理片段中的列表視圖數據。 –

回答

0

使用的ListView與刷卡刷新

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

    <ListView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/listView"> 
    </ListView> 
</android.support.v4.widget.SwipeRefreshLayout> 
+0

我已經使用這種佈局。我有一個與swiperefresh工作的listview,但我想解決,如果我選擇一個項目,並返回到列表視圖不滾動到頂部,並swiperefresh也是wkignign :) – just

0

你描述這個XML代碼不是enough.I認爲這是你的ListView和swipelayout復位,如setAdapter,當從片段的回報。

+0

當我回到列表視圖應用程序自動刷新列表視圖的內容,我不重置手動這些對象,可能自動重置? – just

+0

也許。我不在你的列表視圖,活動或片段? – CoXier

+0

我使用ListFragment – just