国产探花免费观看_亚洲丰满少妇自慰呻吟_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()來設置顏色。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 象州县| 宜城市| 务川| 正宁县| 秭归县| 祁门县| 哈巴河县| 天祝| 大足县| 建昌县| 甘孜| 托克托县| 淳安县| 长沙市| 巩义市| 通化市| 萨迦县| 远安县| 沙坪坝区| 嘉禾县| 观塘区| 玉门市| 遵义县| 宜川县| 汽车| 乐至县| 麦盖提县| 肃南| 肥西县| 馆陶县| 全南县| 信丰县| 涡阳县| 连南| 镇远县| 盐源县| 越西县| 闸北区| 怀仁县| 江达县| 麦盖提县|