標籤:
轉載地址:http://my.oschina.net/cuitongliang/blog/170708
(一)&&http://my.oschina.net/cuitongliang/blog/170737
(二)PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED
一、介紹
Pull To Refresh Views for Android
This project aims to provide a reusable Pull to Refresh widget for Android. It was originally based on Johan Nilsson‘s library (mainly for graphics, strings and animations), but these have been replaced since.
Features
- Supports both Pulling Down from the top, and Pulling Up from the bottom (or even both).
- Animated Scrolling for all devices.
- Over Scroll supports for devices on Android v2.3+.
- Currently works with:
- ListView
- ExpandableListView
- GridView
- WebView
- ScrollView
- HorizontalScrollView
- ViewPager
- Integrated End of List Listener for use of detecting when the user has scrolled to the bottom.
- Maven Support.
- Indicators to show the user when a Pull-to-Refresh is available.
- Support for ListFragment!
- Lots of Customisation options!
Repository at https://github.com/chrisbanes/Android-PullToRefresh.
附源碼:
ListView ExpandableListView
GridView WebView
ScrollView Horizontal ScrollView
ViewPager ListView Fragment
WebView Advanced ListView in ViewPager
二、DEMO匯入
很多人看到有好源碼,但是在使用時碰到了問題。在此簡單介紹一下,希望能夠對那些不會的童鞋們有所協助。
首先下載源碼,源碼地址:https://github.com/chrisbanes/Android-PullToRefresh。
下載完源碼之後,解壓。在Android-PullToRefresh-master檔案夾下,我們會看到還有三個檔案夾:extras,
library,sample。其中sample就是作者為我們提供的Demo,library是我們在使用Sample必須用到的jar。extras中是使用ListFragment和ViewPage用到的jar。講解完目錄後現在開始匯入了。
1. 匯入library:匯入很簡單,,點擊finish即可。
匯入之後沒有問題。OK!
2. 同樣匯入extras中的PullToRefreshListFragment和PullToRefreshViewPager工程。切記:分別匯入。
匯入之後,你會發現工程報錯了,很簡單,沒有關聯libraray。右鍵工程--選擇Properties,開啟之後會發現有個紅色的X,這就是報錯的原因。改了就可以。
選中紅色的報錯的library,點擊Remove,再點擊Add,將Libarary添加上即可!
同理將PullToRefreshViewPager工程的library也修改好。
3. 匯入Sample工程,同時修改library。
至此,工程全部匯入,錯誤全部解決。
運行一下,看是否能夠正常運行到手機上。接下來就可以慢慢研究著精品源碼吧!
感謝原作者詳細的講解,解決了我的問題!
三、DEMO匯入出現問題及解決
一、運行報錯:Unable to execute dex: Multiple dex files define Lcom/my/cop/miles/R$anim
導致原因:
1、在ADT編譯器和SDK的工具有差異或是版本不一致時常會出現
2、引用的兩個子項目有相同的包名也會導致這個問題(引用多餘的jar包,包出現衝突)
解決方案:
Eclipse ——> Project ——> 去掉自動構建(Build Automatically)——> 選擇project中的clear ——> 選擇project中的Build Project ——>啟動自動構建(Build Automatically)
國外源碼精品-Android-PullToRefresh 簡介與DEMO匯入