我正在学习android刷卡刷新布局。我在swipeRefreshLayout“setRefreshing(true)”上发布了runabble,然后在方法onRefresh上写了fetchMovie()。但是fetchMovie()没有调用。如何解决?
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span> <span
class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
{{ Html::image('assets/images/logo.png') }}
</a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li class=""><a href="#">About Us</a></li>
</ul>
</div>
</div>
</header>
答案 0 :(得分:4)
如有关 SwipeRefreshLayout 的文档中所示:
如果活动希望仅显示进度动画,则应调用setRefreshing(true)。
调用setRefreshing()将不会调用OnRefreshListener。你可以在它之后调用fetchMovie():
swipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(true);
fetchMovie();
}
});
相关文档:https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html