国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Google自己的下拉刷新組件SwipeRefreshLayout

2019-11-09 15:09:43
字體:
來源:轉載
供稿:網友

感謝原文作者:http://stormzhang.github.io/android/2014/03/29/android-swiperefreshlayout/

API doc:http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html首先須把你的support library的版本升級到19.1或更新

效果:

使用超級簡單!

在layout中添加SwipeRefreshLayout

復制代碼
 1 <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     android:id="@+id/swipe_container" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" > 5  6     <ScrollView 7         android:layout_width="match_parent" 8         android:layout_height="wrap_content" > 9 10         <TextView11             android:id="@+id/textView1"12             android:layout_width="match_parent"13             android:layout_height="wrap_content"14             android:gravity="center"15             android:paddingTop="10dp"16             android:text="@string/swipe_to_refresh"17             android:textSize="20sp"18             android:textStyle="bold" />19     </ScrollView>20 21 </android.support.v4.widget.SwipeRefreshLayout>復制代碼

在Activity中使用:

復制代碼
 1 tv = (TextView)findViewById(R.id.textView1); 2         swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipe_container); 3         //設置刷新時動畫的顏色,可以設置4個 4         swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); 5         swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { 6              7             @Override 8             public void onRefresh() { 9                 tv.setText("正在刷新");10                 // TODO Auto-generated method stub11                 new Handler().postDelayed(new Runnable() {12                     13                     @Override14                     public void run() {15                         // TODO Auto-generated method stub16                         tv.setText("刷新完成");17                         swipeRefreshLayout.setRefreshing(false);18                     }19                 }, 6000);20             }21         });復制代碼

PS:setColorScheme()已經棄用,使用setColorSchemeResources()來設置顏色。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒲江县| 奉新县| 襄樊市| 连州市| 上饶市| 左云县| 上饶市| 唐山市| 罗江县| 右玉县| 天峻县| 黎城县| 泰来县| 绿春县| 静海县| 灵宝市| 钟祥市| 高安市| 昆山市| 三河市| 巨野县| 博罗县| 芦溪县| 莲花县| 油尖旺区| 宜川县| 汶上县| 枝江市| 铁岭县| 普格县| 崇信县| 临桂县| 乌恰县| 宁武县| 平邑县| 长泰县| 涞水县| 陇川县| 平江县| 利津县| 佳木斯市|