Android SwipeRefreshLayout仿抖音app靜態(tài)刷新
SwipeRefreshLayout的功能就是可以讓我們的界面在不動的情況下,下拉直接刷新
廢話不多說,效果圖奉上:

activity_listview布局文件
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/sr1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.SwipeRefreshLayout>
Activity代碼(ListViewActivity)
public class ListViewActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
private SwipeRefreshLayout swipeRefreshLayout;
private ListView listView;
private List<String> list;
private ArrayAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.sr1);
swipeRefreshLayout.setOnRefreshListener(this);
list = new ArrayList<>();
list.add("ssss");
listView = (ListView) findViewById(R.id.lv);
adapter = new ArrayAdapter(this
, android.R.layout.simple_list_item_1
, android.R.id.text1
, list);
listView.setAdapter(adapter);
}
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(false);
adapter.clear();
list.add("1111");
adapter.notifyDataSetChanged();
}
}, 1000);
}
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android SwipeRefreshLayout超詳細(xì)講解
- Android 使用SwipeRefreshLayout控件仿抖音做的視頻下拉刷新效果
- android使用SwipeRefreshLayout實現(xiàn)ListView下拉刷新上拉加載
- android基于SwipeRefreshLayout實現(xiàn)類QQ的側(cè)滑刪除
- Android 中SwipeRefreshLayout與ViewPager滑動事件沖突解決方法
- android中SwipeRefresh實現(xiàn)各種上拉,下拉刷新示例
- Android使用Item Swipemenulistview實現(xiàn)仿QQ側(cè)滑刪除功能
- Android實現(xiàn)SwipeRefreshLayout首次進(jìn)入自動刷新
- Android 中 Swipe、Scroll 和 Fling 的區(qū)別解析
相關(guān)文章
Android復(fù)選框CheckBox與開關(guān)按鈕Switch及單選按鈕RadioButton使用示例詳解
這篇文章主要介紹了Android復(fù)選框CheckBox與開關(guān)按鈕Switch及單選按鈕RadioButton使用示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2022-09-09
Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫訪問實例
下面小編就為大家分享一篇Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫訪問實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-02-02
Android使用開源框架ANDROID-IMAGE-INDICATOR實現(xiàn)圖片輪播部署
這篇文章主要為大家詳細(xì)介紹了Android使用開源框架ANDROID-IMAGE-INDICATOR實現(xiàn)圖片輪播部署,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01
Android 限制edittext 整數(shù)和小數(shù)位數(shù) 過濾器(詳解)
下面小編就為大家?guī)硪黄狝ndroid 限制edittext 整數(shù)和小數(shù)位數(shù) 過濾器(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04
android kotlin集成WorkManager實現(xiàn)定時獲取數(shù)據(jù)的步驟
在Android中使用Kotlin集成WorkManager來實現(xiàn)定時獲取數(shù)據(jù)是一個很常見的需求,下面給大家分享android kotlin集成WorkManager實現(xiàn)定時獲取數(shù)據(jù)的步驟,感興趣的朋友跟隨小編一起看看吧2024-08-08

