片段刷新 [英] Fragment Refresh

查看:106
本文介绍了片段刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试刷新片段类而不从片段中分离。
我已经通过sqlite插入了一些数据,但除非我重启我的应用程序,否则更改不会显示。请具体说明添加刷新代码的位置以及代码。

I am trying to refresh a fragment class without detaching from fragment. I have inserted some data by sqlite but unless I restart my application that change doesn't show up. Please be specific where to add refreshing code and what will be the code.

推荐答案

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

这篇关于片段刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆