2017-01-04 109 views
0

我想刷新一个片段类而不从片段分离。 我已经通过sqlite插入了一些数据,但除非我重新启动我的应用程序,更改不显示。请具体在哪里添加刷新代码以及代码是什么。片段刷新

+0

发布相关的代码片段。 –

+0

您应该添加您的代码,以提供您遇到的问题的更多上下文。 – riggaroo

+0

刚刚解决了这个问题。谢谢你们的关注。我在这里添加我的解决方案。 –

回答

0
I haved solved the issue by adding swipe refresh layout. Here is my code : 

this is refresh layout : 

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



this is refresh listener : 

swipeContainer = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); 
     swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 
      @Override 
      public void onRefresh() { 
       //do all refreshing tasks 
       swipeContainer.setRefreshing(false); 
      } 
     });