Android SwipeRefreshLayout仿抖音app靜態(tài)刷新
SwipeRefreshLayout的功能就是可以讓我們的界面在不動(dòng)的情況下,下拉直接刷新
廢話(huà)不多說(shuō),效果圖奉上:
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); } }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android SwipeRefreshLayout超詳細(xì)講解
- Android 使用SwipeRefreshLayout控件仿抖音做的視頻下拉刷新效果
- android使用SwipeRefreshLayout實(shí)現(xiàn)ListView下拉刷新上拉加載
- android基于SwipeRefreshLayout實(shí)現(xiàn)類(lèi)QQ的側(cè)滑刪除
- Android 中SwipeRefreshLayout與ViewPager滑動(dòng)事件沖突解決方法
- android中SwipeRefresh實(shí)現(xiàn)各種上拉,下拉刷新示例
- Android使用Item Swipemenulistview實(shí)現(xiàn)仿QQ側(cè)滑刪除功能
- Android實(shí)現(xiàn)SwipeRefreshLayout首次進(jìn)入自動(dòng)刷新
- Android 中 Swipe、Scroll 和 Fling 的區(qū)別解析
相關(guān)文章
Android中實(shí)現(xiàn)EditText圓角的方法
Android中實(shí)現(xiàn)EditText圓角的方法,需要的朋友可以參考一下2013-03-03Android復(fù)選框CheckBox與開(kāi)關(guān)按鈕Switch及單選按鈕RadioButton使用示例詳解
這篇文章主要介紹了Android復(fù)選框CheckBox與開(kāi)關(guān)按鈕Switch及單選按鈕RadioButton使用示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧2022-09-09Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫(kù)訪(fǎng)問(wèn)實(shí)例
下面小編就為大家分享一篇Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫(kù)訪(fǎng)問(wèn)實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02Android使用開(kāi)源框架ANDROID-IMAGE-INDICATOR實(shí)現(xiàn)圖片輪播部署
這篇文章主要為大家詳細(xì)介紹了Android使用開(kāi)源框架ANDROID-IMAGE-INDICATOR實(shí)現(xiàn)圖片輪播部署,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01Android 限制edittext 整數(shù)和小數(shù)位數(shù) 過(guò)濾器(詳解)
下面小編就為大家?guī)?lái)一篇Android 限制edittext 整數(shù)和小數(shù)位數(shù) 過(guò)濾器(詳解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-04-04android kotlin集成WorkManager實(shí)現(xiàn)定時(shí)獲取數(shù)據(jù)的步驟
在A(yíng)ndroid中使用Kotlin集成WorkManager來(lái)實(shí)現(xiàn)定時(shí)獲取數(shù)據(jù)是一個(gè)很常見(jiàn)的需求,下面給大家分享android kotlin集成WorkManager實(shí)現(xiàn)定時(shí)獲取數(shù)據(jù)的步驟,感興趣的朋友跟隨小編一起看看吧2024-08-08一次OOM問(wèn)題排查過(guò)程實(shí)戰(zhàn)記錄
這篇文章主要給大家介紹了一次OOM問(wèn)題排查過(guò)程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05