【问题标题】:Fragment Refresh片段刷新
【发布时间】:2017-01-04 16:43:06
【问题描述】:

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

【问题讨论】:

  • 贴出相关代码sn-ps。
  • 您应该添加您的代码以提供您遇到的问题的更多上下文。
  • 刚刚解决了这个问题。谢谢大家的关注。我在这里添加我的解决方案。

标签: java android android-fragments


【解决方案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);
            }
        });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多