我对Android非常陌生,我正在探索谷歌网站上的示例代码。我目前使用的代码是SwipeRefreshLayout:http://developer.android.com/samples/SwipeRefreshLayoutBasic/index.htmlSwipeRefreshLayout:滑动进度动画
在代码中,我们看到为列表视图执行SwipeRefreshLayout,换句话说,如果您向下拖动列表视图,该方法被触发并且列表视图自我刷新。
<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>
什么是困惑我的是,有在该得到的,当你向下拖动列表视图的顶部显示的进度动画条的代码没有布局。您是否认为SwipeRefreshLayout自动生成一个进度动画栏,而不需要用户在xml中为其指定任何布局?
例如,如果想要在进度动画栏的两端填充填充,以便在刷新时动画不会触摸屏幕的末端,那么将如何进行?
https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html对此没有任何说法。
谢谢。我认为你是对的,除了设置进度条的颜色外,没有什么可以自定义的。你还知道SwipeRefreshLayout类是否自动为列表视图操作notifyDataChanged()方法?在用户通过mListAdapter.add(cheese)方法下拉3秒钟后,listview会自动刷新,但notifyDataChanged()方法从未被调用来通知列表视图对其数据所做的更改。 – Simon
不,它不。您可以检查自己的代码,在您的sdk目录中搜索'SwipeRefreshLayout.java'。您需要安装支持v4库的最新版本(修订19.1.0) –
的源代码所以我猜想listview是从数据添加到适配器时自动刷新的:mListAdapter.add(cheese)? – Simon