國外源碼精品-Android-PullToRefresh 簡介與DEMO導入


轉載地址: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)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM