![【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多_第1頁](http://file4.renrendoc.com/view/afe5b8182b01923cd0222b942dd01dbc/afe5b8182b01923cd0222b942dd01dbc1.gif)
![【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多_第2頁](http://file4.renrendoc.com/view/afe5b8182b01923cd0222b942dd01dbc/afe5b8182b01923cd0222b942dd01dbc2.gif)
![【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多_第3頁](http://file4.renrendoc.com/view/afe5b8182b01923cd0222b942dd01dbc/afe5b8182b01923cd0222b942dd01dbc3.gif)
![【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多_第4頁](http://file4.renrendoc.com/view/afe5b8182b01923cd0222b942dd01dbc/afe5b8182b01923cd0222b942dd01dbc4.gif)
![【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多_第5頁](http://file4.renrendoc.com/view/afe5b8182b01923cd0222b942dd01dbc/afe5b8182b01923cd0222b942dd01dbc5.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
【移動應用開發(fā)技術(shù)】android如何使用PullToRefresh框架實現(xiàn)ListView下拉刷新上拉加載更多
/upload/information/20200623/125/125180.gif/upload/information/20200623/125/125181.png<LinearLayout
xmlns:android="/apk/res/android"
xmlns:tools="/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--
我們添加了一個屬性:ptr:ptrMode="both"
,意思:上拉和下拉都支持。
可選值為:disabled(禁用下拉刷新),pullFromStart(僅支持下拉刷新),
pullFromEnd(僅支持上拉刷新),both(二者都支持),manualOnly(只允許手動觸發(fā))
-->
<!--
ptr:ptrAnimationStyle="rotate"
FlipLoadingLayout為iOS風格的箭頭顛倒的刷新動畫
ptr:ptrAnimationStyle="flip"
RotateLoadingLayout為android風格的圖片旋轉(zhuǎn)動畫
-->
<com.ptrflv.www.pulltorefreshlistview.PullToRefreshListView
xmlns:ptr="/apk/res-auto"
android:id="@+id/pull_to_refresh_listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ptr:ptrMode="both"
ptr:ptrAnimationStyle="flip"
/>
</LinearLayout><?xml
version="1.0"
encoding="utf-8"?>
<resources>
<!--
上拉刷新
-->
<!--
…代表三個點
...
-->
<string
name="pull_to_refresh_pull_label">向下拉刷新…</string>
<string
name="pull_to_refresh_release_label">松開更新…</string>
<string
name="pull_to_refresh_refreshing_label">正在加載…</string>
<!--
下拉加載更多
-->
<string
name="pull_to_refresh_from_bottom_pull_label">向下拉加載更多…</string>
<string
name="pull_to_refresh_from_bottom_release_label">松開加載更多…</string>
<string
name="pull_to_refresh_from_bottom_refreshing_label">正在加載…</string>
</resources>public
class
MainActivity
extends
Activity
{
private
PullToRefreshListView
pullToRefreshListView;
//adapter的數(shù)據(jù)源
private
List<String>
numList=new
ArrayList<String>();
private
ArrayAdapter<String>
arrayAdapter;
@Override
protected
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pullToRefreshListView=(PullToRefreshListView)
findViewById(R.id.pull_to_refresh_listview);
//初始化數(shù)據(jù)
for(int
x=0;x<18;x++){
numList.add(""+x);
}
arrayAdapter
=
new
ArrayAdapter<String>(this,
R.layout.item_listview,R.id.textview,numList);
pullToRefreshListView.setAdapter(arrayAdapter);
//設(shè)定刷新監(jiān)聽
pullToRefreshListView.setOnRefreshListener(new
OnRefreshListener<ListView>()
{
@Override
public
void
onRefresh(PullToRefreshBase<ListView>
refreshView)
{
String
label
=
DateUtils.formatDateTime(getApplicationContext(),
System.currentTimeMillis(),
DateUtils.FORMAT_SHOW_TIME
|
DateUtils.FORMAT_SHOW_DATE
|
DateUtils.FORMAT_ABBREV_ALL);
//
顯示最后更新的時間
refreshView.getLoadingLayoutProxy()
.setLastUpdatedLabel(label);
//代表下拉刷新
if(refreshView.getHeaderLayout().isShown()){
new
Thread(){
public
void
run()
{
try
{
sleep(1000);
handler.sendEmptyMessage(99);
}
catch
(InterruptedException
e)
{
e.printStackTrace();
}
};
}.start();
}
//代表下拉刷新
if(refreshView.getFooterLayout().isShown()){
new
Thread(){
public
void
run()
{
try
{
sleep(1000);
handler.sendEmptyMessage(98);
}
catch
(InterruptedException
e)
{
e.printStackTrace();
}
};
}.start();
}
}
});
}
private
Handler
handler=new
Handler(){
public
void
handleMessage(android.os.Message
msg)
{
if(msg.what==99){
numList.add(0,
"英雄聯(lián)盟");
arrayAdapter.notifyDataSetChanged();
//關(guān)閉刷新的動畫
pullToRefreshListView.onRefreshComplete();
}
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030全球滑靴式分揀系統(tǒng)行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球民用航空機翼行業(yè)調(diào)研及趨勢分析報告
- 為他人貸款合同擔保
- 叉車購銷合同模板
- 2025物料購置合同管理操作規(guī)程
- 學校商鋪租賃合同范本
- 提高組織和協(xié)調(diào)能力的培訓
- 施工設(shè)計合同
- 商鋪租賃合同范本簡單
- 人才招聘中介服務合同模板
- 學校財務年終工作總結(jié)4
- 2025年人民教育出版社有限公司招聘筆試參考題庫含答案解析
- 康復醫(yī)學治療技術(shù)(士)復習題及答案
- 《血管性血友病》課件
- 2024-2025學年人教版七年級數(shù)學上冊期末達標測試卷(含答案)
- 2024年安全員-C證考試題庫及答案(1000題)
- 高二數(shù)學下學期教學計劃
- 文學類作品閱讀練習-2023年中考語文考前專項練習(浙江紹興)(含解析)
- 第五章硅酸鹽分析
- 外科學總論-第十四章腫瘤
- 網(wǎng)絡反詐知識競賽參考題庫100題(含答案)
評論
0/150
提交評論