I\'m quite new to android and I\'m exploring the sample code on google website. The code I\'m on currently is the SwipeRefreshLayout: http://developer.android.com/samples/Sw
although you can't change it, you can still hide it and then display your own once triggered :-)
SwipeRefreshLayout swiperefresh = (SwipeRefreshLayout)root.findViewById(R.id.swiperefresh);
swiperefresh.setOnRefreshListener(this);
swiperefresh.setColorSchemeColors(0,0,0,0);
swiperefresh.setProgressBackgroundColor(android.R.color.transparent);
Notes:
in eclipse you have to add @SuppressLint("ResourceAsColor") to compile this.
you still need to call setRefreshing(false) at an appropriate point in time else onRefresh doesn't trigger again.
You can't change the animation.
In SwipeRefreshLayout
you can't customize much; I believe this is an attempt of Google to get developers stick to common patterns. What you can style are the four colors of the animation, specified with setColorScheme()
.
SwipeRefreshLayout
takes care to show its predefined animation at its top for you. This can be when canChildScrollUp()
returns false and user 'pulls down', or when you set setRefreshing(true)
. Turn off the animation with setRefreshing(false)
. Put your logic in the method onRefreshing()
of the listener. Override canChildScrollUp()
if you put something that is not a ListView
in your SwipeRefreshLayout
. You should be good to go from here.