牙叔教程 简单易懂
/* * @version: 1.0 * @Date: 2021-12-29 18:39:14 * @LastEditTime: 2021-12-29 22:17:08 * @LastEditors: 牙叔 * @Description: * @FilePath: \recyclerView添加header和footer\main.js * @名人名言: 牙叔教程 简单易懂 * @bilibili: 牙叔教程 * @公众号: 牙叔教程 * @QQ群: 747748653 */ "ui"; importClass(Packages.androidx.recyclerview.widget.LinearLayoutManager); importClass(Packages.androidx.recyclerview.widget.RecyclerView); importClass(android.graphics.Color); importClass(Packages.androidx.swiperefreshlayout.widget.SwipeRefreshLayout); ui.layout( <vertical gravity="center"> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout id="swipeRefreshLayout" android:layout_width="match_parent" android:layout_height="wrap_content" > <androidx.recyclerview.widget.RecyclerView id="recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </vertical> ); let refreshing = false; let swipeRefreshLayout = ui.swipeRefreshLayout; swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener({ onRefresh: function () { if (refreshing) { com.google.android.material.snackbar.Snackbar.make(ui.swipeRefreshLayout, "数据处理中", 1000).show(); return; } refreshing = true; setTimeout(() => { swipeRefreshLayout.setRefreshing(false); refreshing = false; }, 5000); }, }) );
名人名言
思路是最重要的, 其他的百度, bing, stackoverflow, github, 安卓文档, autojs文档, 最后才是群里问问
--- 牙叔教程
声明
部分内容来自网络
本教程仅用于学习, 禁止用于其他用途