This paper takes the introduction of Https://github.com/chrisbanes/Android-PullToRefresh as an example
Reference: http://www.apkbus.com/android-125663-1-1.html
The Android studio on my Computer is 1.2.1.1, SDK api22.
Create a project normally (project is named "Demo" in this example)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/D9/wKioL1Vtga-AxpLCAAFJQgLJeHw467.jpg "title=" Demo1.png "alt=" Wkiol1vtga-axplcaafjqgljehw467.jpg "/>
Start introducing the Pulltorefresh class library to your project
Press the "F12" or File->new->import module on the keyboard as follows
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/DD/wKiom1VtgH3j1zf5AAGWu890C1o454.jpg "title=" Demo2.png "alt=" Wkiom1vtgh3j1zf5aagwu890c1o454.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/DD/wKiom1VtgRPiQlMeAAJ0Eivrae8684.jpg "title=" Demo3.png "alt=" Wkiom1vtgrpiqlmeaaj0eivrae8684.jpg "/>
Import the library, Extras\pulltorefreshlistfragment, extras\pulltorefreshlistfragment in the Android-pulltorefresh directory in turn
After the completion of the directory as follows
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6D/DD/wKiom1VtgqDwL21sAAGg2rylZGY519.jpg "title=" Demo4.png "alt=" Wkiom1vtgqdwl21saagg2rylzgy519.jpg "/>
B. Add class library dependencies for app modules under demo.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/D9/wKioL1VthNviOq41AAHLZI465WE788.jpg "title=" Demo6.png "alt=" Wkiol1vthnvioq41aahlzi465we788.jpg "/>
The result is as above when finished. Click "OK" to complete.
3. Troubleshooting compilation Errors
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/D9/wKioL1VthYmgFcufAANImBV_-tQ811.jpg "title=" Demo7.png "alt=" Wkiol1vthymgfcufaanimbv_-tq811.jpg "/>
Re-press "F12" to modify the Min SDK and Target SDK versions in the other three modules except apps, same as app
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/DE/wKiom1VthbCRbafAAAJMxHnLMTE954.jpg "title=" Demo8.png "alt=" Wkiom1vthbcrbafaaajmxhnlmte954.jpg "/>
OK, the compilation will pass normally.
4. Add a test example.
Modified: Layout/activity_main.xml File
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android " xmlns:tools=" Http://schemas.android.com/tools " android: Layout_width= "Match_parent" android:layout_height= "Match_parent" tools:context= "demo.zhezi.MainActivity" android:orientation= "vertical" > <com.handmark.pulltorefresh.library.PullToRefreshListView android:id= "@+id/listview" android: Layout_width= "Fill_parent" android:layout_height= "Fill_parent" > </com.handmark.pulltorefresh.library.pulltorefreshlistview></ Linearlayout>
modify: Mainactivity.java file
private pulltorefreshlistview listview ;p rivate arrayadapter<string> Arrayadapter, @Overrideprotected void oncreate (bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (R.layout.activity_main);listview = (PullToRefreshListView) Findviewbyid (R.id.listview);arrayadapter = new arrayadapter<string> (this, android. r.layout.simple_list_item_1), Arrayadapter.add ("Welcome"), Arrayadapter.add ("welcome1"); Arrayadapter.add (" Welcome2 "); Arrayadapter.add (" Welcome3 "); Listview.setadapter (Arrayadapter); Listview.setonrefreshlistener (new OnRefreshListener<ListView> () {@Overridepublic void onrefresh (pulltorefreshbase< Listview> refreshview) {new AsyncTask<Void, Void, Void> ( {@) Overrideprotected void doinbackground (void... params) {try {thread.sleep (3000);} catch (interruptedexception e) &NBSp {E.printstacktrace ();} Return null;} Protected void onpostexecute (Void result) {arrayadapter.addall ("Hello", "good everyone"); Listview.onrefreshcomplete ();};}. Execute ();}});
All right. The results are shown below
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/DE/wKiom1Vth5iyfYnXAADTZ0WTGLc307.jpg "style=" float: none; "title=" Demo9.png "alt=" Wkiom1vth5iyfynxaadtz0wtglc307.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/D9/wKioL1VtiTLDHZfoAAC0Z10OivI438.jpg "style=" float: none; "title=" Demo10.png "alt=" Wkiol1vtitldhzfoaac0z10oivi438.jpg "/>
This article is from the "Peter's Future" blog, so be sure to keep this source http://peterxu.blog.51cto.com/1391852/1657631
Introduction of third party Lib in Android studio project