标签: pull-to-refresh

如何用里面的两个视图刷新SwipeRefreshLayout

我已经SwipeRefreshLayout有两个孩子:RecyclerViewLinearLayout 让我不得不定制RecyclerView:

recycler_view.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            // int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
            // swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
            if (!defined) {
                toolbarHeight = ll_header.getMeasuredHeight() + 15;
                footerHeight = ll_footer.getMeasuredHeight() + 15;
                defined = true;
            }
            clipToolbarOffset();
            if ((toolbarOffset < toolbarHeight && dy > 0) || (toolbarOffset > 0 && dy < 0)) {
                toolbarOffset += dy;
            }
            if ((footerOffset < footerHeight …
Run Code Online (Sandbox Code Playgroud)

android pull-to-refresh swiperefreshlayout

2
推荐指数
2
解决办法
2727
查看次数

在NavBar上使用Back之后,RefreshControl会在TableView的第一个单元格中造成bug

我有一个TableView嵌入在NavigationController中(并且它嵌入在TabBar控制器中)。每个单元格中都有一个用户名按钮,可以与用户的个人资料建立联系。

在此处输入图片说明

但是,当我在个人资料页面的导航栏上单击“返回”,并直接返回到表格视图后,似乎我在窃听一些东西。

在此处输入图片说明

在此处输入图片说明

如果我再次下拉,它会刷新,但是这次,第一行的用户名变得不可单击,而其他行则按预期工作。

请注意,在使用“后退”按钮后,我在tableView中进行了调用self.theRefreshControl = UIRefreshControl()viewDidLoad但不确定是否正在调用它。

请注意,我使用进行搜寻prepareForSegue


总结

  • 如果我转到通知页面并尝试单击用户名,则单击用户名按钮并进行搜索

  • 如果我转到通知,然后单击刷新,则第一行中的用户名按钮不起作用

  • 如果我转到通知并且不进行任何刷新,则用户名按钮会自动切换并返回(因此不会出错)。

  • 如果我转到通知并拉动刷新,则refreshControl图标会出现并消失,但是现在,它不允许我单击第一行的用户名按钮。

  • 如果我确实刷新了通知,则不允许我单击第一行中的用户名。如果我单击第二个单元格中的第二个用户名,它将搜索到用户的个人资料,但是当我单击“后退”按钮时,它将出现如下错误:

在此处输入图片说明

ViewDidLoad()中的代码:

 override func viewDidLoad() {
  super.viewDidLoad()

  self.theRefreshControl = UIRefreshControl()
  self.theRefreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
  self.theRefreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
  self.tableView.addSubview(theRefreshControl)
}

func refresh(sender: AnyObject) {
   if isFirstLoad == false {
      currentPage = 1
       getStuff()
    }

   self.theRefreshControl.endRefreshing()
}
Run Code Online (Sandbox Code Playgroud)

我也尝试self.tableView.backgroundView = refreshControl在上方和下方添加self.tableView.addSubview(theRefreshControl);并且还试图更换self.tableView.addSubview(theRefreshControl)self.tableView.backgroundView = refreshControl可惜没有运气

uitableview ios pull-to-refresh swift

2
推荐指数
1
解决办法
1073
查看次数

如何在 WebView 中添加 Pull to Refresh?

我对开发很陌生。我正在构建一个 WebView,我希望它具有拉动刷新功能。我该如何快速做到这一点?

我在视图控制器中的代码是

@IBOutlet var webView: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    func webViewDidFinishLoad(webView: UIWebView) {
        UIApplication.sharedApplication().networkActivityIndicatorVisible = false
    }

    func webViewDidStartLoad(webView: UIWebView) {
        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
    }

    let url = NSURL (string: "https://www.foo.com");
    let requestObj = NSURLRequest(URL: url!);
    webView.loadRequest(requestObj);
    NSUserDefaults.standardUserDefaults().registerDefaults(["UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"])
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}
Run Code Online (Sandbox Code Playgroud)

uiwebview webview ios pull-to-refresh swift

2
推荐指数
1
解决办法
7701
查看次数

颤动:使用RefreshIndicator时没有刷新指示器

我在页面上添加了RefreshIndicator,但是在刷新时没有可见的指示器。代码如下:

class HomePage extends StatefulWidget {
  HomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<HomePage> {

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: LocalGalleryTab(),
    );
  }
}

class LocalGalleryTab extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _LocalGalleryState();
  }
}

class _LocalGalleryState extends State<LocalGalleryTab> {
  @override
  Widget build(BuildContext context) {
    return new Container(child: new Center(
      child: new RefreshIndicator(
        child: Text("Local …
Run Code Online (Sandbox Code Playgroud)

pull-to-refresh flutter

2
推荐指数
5
解决办法
3875
查看次数

How to include 3rd party module (angular-pull-to-refresh), which has no type definitions

I'm a complete beginner and I don't have any idea, how include libraries and inject module, so please, bear with me. This is the module I want to include: https://github.com/mgcrea/angular-pull-to-refresh

我用凉亭安装了模块并成功链接了它们。应该在 app.component.html 中,对吗?或者我应该将它链接到名为 list ( list.component.html) 的组件中,在那里我显示数据,我想用下拉刷新?

你能指出我正确的方向吗,把这条线放在哪里以及“myApp”在这里代表什么。
- 将mgcrea.pullToRefresh模块注入您的应用程序:
angular.module('myApp', ['mgcrea.pullToRefresh']);

在示例中,pull-to-refresh属性被调用并在函数 onReload() 内。这个函数应该放在什么地方?

感谢大家阅读和帮助我!

module angularjs pull-to-refresh

2
推荐指数
1
解决办法
1463
查看次数

如何添加拉动刷新控制器到滚动视图?

嗨,在我的应用程序中,我想添加 Pull 以刷新控制器以滚动视图。我编写了以下代码,但没有得到任何响应。

当我滚动视图时,不会调用添加目标方法。

@IBOutlet var scrool: UIScrollView!
var refreshControl = UIRefreshControl()

override func viewDidLoad() {
        super.viewDidLoad()
        // Add refresh control for the Home page scroll view.
        self.refreshControl.tintColor = UIColor.appcolor
        self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
        self.refreshControl.addTarget(self, action: #selector(refresh(sender:)), for: UIControl.Event.valueChanged)
        self.scrool.isScrollEnabled = true
        self.scrool.alwaysBounceVertical = true
        scrool.addSubview(refreshControl)
    }
    @objc func refresh(sender:AnyObject) {
        // Code to refresh table view
        self.getHomePageApi()
        refreshControl.endRefreshing()

    }
Run Code Online (Sandbox Code Playgroud)

scrollview ios pull-to-refresh swift

2
推荐指数
1
解决办法
4886
查看次数

手动拉入 PullToRefresh 不起作用(使用可复制示例)

我试图从材质库中实现 PullToRefresh 组件,但即使一对一复制 Google 自己的代码,滑动也不会触发任何内容。https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/package-summary.html

我已经能够将他们的代码减少到最小的可复制示例。加载器将显示您是否手动将其设置为 true,但不会在滑动时触发。

该视图不需要任何其他内容,例如,无论 Box 组件中还有什么内容,加载程序都应该显示。

import androidx.compose.foundation.layout.*
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun PullToRefreshComposableTEST() {

    var loading by remember {
        mutableStateOf(true)
    }

    val pullRefreshState = rememberPullRefreshState(
        refreshing = loading,
        onRefresh = {
            loading = true
        })

    Box(
        Modifier.fillMaxSize().pullRefresh(pullRefreshState)
    ) {
        PullRefreshIndicator(
            modifier = Modifier.align(Alignment.TopCenter),
            refreshing = loading,
            state = pullRefreshState
        )
    }
}

@Preview(showSystemUi = true)
@Composable
private fun Preview() { …
Run Code Online (Sandbox Code Playgroud)

android kotlin pull-to-refresh android-jetpack-compose

2
推荐指数
1
解决办法
1237
查看次数

在android中自动滚动PullToRefreshScrollview

我在PullToRefreshScrollview中有一个Listview,FrameLayout.我正在将一个片段加载到framelayout中.使用延迟适配器将数据加载到listview中.我可以在listview加载时看到fragment/framelayout.但是,在将数据加载到listview并且framelayout不可见之后,Scrollview会自动滚动到listview的位置.如何将滚动视图滚动到顶部?请帮我.提前致谢

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg"
android:orientation="vertical" >


<com.handmark.pulltorefresh.library.PullToRefreshScrollView
    xmlns:ptr="http://schemas.android.com/apk/res-auto"
    android:id="@+id/ptrScrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="5dp"
    android:layout_weight="1"
    android:paddingBottom="5dp"
    ptr:ptrMode="pullUpFromBottom" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </FrameLayout>

        <com.xxxx.yyyy.CustomListView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/app_bg"
            android:focusable="false"  />

        <ProgressBar
            android:id="@+id/spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="gone" />
    </LinearLayout>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>



 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android scrollview pull-to-refresh

1
推荐指数
1
解决办法
1454
查看次数

ActionBar-PullToRefresh与ActionBarSherlock

我正在尝试在我的项目中使用这两个库但是我收到以下错误:

引起:java.lang.IllegalStateException:此HeaderTransformer旨在在SDK 14+上运行.如果使用ActionBarSherlock或ActionBarCompat,则应使用适当的额​​外提供.

我从这里https://github.com/chrisbanes/ActionBar-PullToRefresh下载了ActionBar-PullToRefresh库,并将文件夹库导入我的工作区.如何将文件夹附加项导入此项目以使其工作?

我在eclipse btw工作.

编辑:

我将文件夹附加内容复制到项目中,但我在其中一个文件中出现错误,如下所示:

在此输入图像描述

编辑2: 在此输入图像描述

android actionbarsherlock pull-to-refresh

1
推荐指数
1
解决办法
2813
查看次数

UITable下拉刷新崩溃应用程序

一切似乎都正确加载,但当我在我的应用程序中拉下我的表视图时它崩溃了,我不知道为什么.我错过了一段代码吗?

继承我的viewController代码:

import UIKit
import Firebase
import FirebaseDatabase

class FindPartiesViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    // where we will store all the parties
    var parties = [party]()

    @IBOutlet weak var partyTable: UITableView!

    var refreshControl = UIRefreshControl()

    override func viewDidLoad() {
        super.viewDidLoad()

        partyTable.delegate = self
        partyTable.dataSource = self
Run Code Online (Sandbox Code Playgroud)

设置刷新控件:

        self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
        self.refreshControl.addTarget(self, action: Selector(("refresh:")), for: UIControlEvents.valueChanged)
        self.partyTable?.addSubview(refreshControl)

        let ref = FIRDatabase.database().reference()

        // go to firebase and get all the parties and all there info
        ref.child("parties").queryOrderedByKey().observe(.childAdded, with: {
            snapshot …
Run Code Online (Sandbox Code Playgroud)

uitableview pull-to-refresh swift

1
推荐指数
1
解决办法
1243
查看次数