我正在尝试刷新片段类而不从片段中分离。 我已经通过sqlite插入了一些数据,但除非我重新启动我的应用程序,否则更改不会显示。请具体说明添加刷新代码的位置以及代码。
答案 0 :(得分:1)
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);
}
});