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

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.