> SwipeLayout /** * 侧拉删除控件 * @author poplar * */ public class SwipeLayout extends FrameLayout {...mSwipeLayout); void onOpen(SwipeLayout mSwipeLayout); void onDraging(SwipeLayout mSwipeLayout); /.../ 要去关闭 void onStartClose(SwipeLayout mSwipeLayout); // 要去开启,这时候需要其他开启的关闭 void onStartOpen(SwipeLayout...mSwipeLayout); } public SwipeLayout(Context context) { this(context, null); } public SwipeLayout...} @Override public void onDraging(SwipeLayout mSwipeLayout) { } @Override public void onClose(SwipeLayout
完整示例代码请看: GitHub 地址 主要源码: public class SwipeLayout extends FrameLayout { public static final int...View mTopView; private View mBottomView; private ViewDragHelper mViewDragHelper; public SwipeLayout...(Context context) { this(context, null); } public SwipeLayout(Context context, AttributeSet...attrs) { this(context, attrs, 0); } public SwipeLayout(Context context, AttributeSet...swipeLayout); void onCloseListener(SwipeLayout swipeLayout); void onClickListener(
> SwipeLayout /** * 侧拉删除控件 * @author poplar * */ public class SwipeLayout extends FrameLayout...mSwipeLayout); void onOpen(SwipeLayout mSwipeLayout); void onDraging(SwipeLayout mSwipeLayout); /.../ 要去关闭 void onStartClose(SwipeLayout mSwipeLayout); // 要去开启,这时候需要其他开启的关闭 void onStartOpen(SwipeLayout...mSwipeLayout); } public SwipeLayout(Context context) { this(context, null); } public SwipeLayout...} @Override public void onDraging(SwipeLayout mSwipeLayout) { } @Override public void onClose(SwipeLayout
先附上图: image.png xml资源文件 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeLayout...>(this, android.R.layout.simple_list_item_1, getData())); /*获取SwipeRefreshLayout*/ swipeLayout...= (SwipeRefreshLayout) findViewById(R.id.swipeLayout); /*设置下拉刷新监听器*/ swipeLayout.setOnRefreshListener...SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeLayout.postDelayed...Runnable() { @Override public void run() { swipeLayout.setRefreshing
MainActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener { private SwipeRefreshLayout swipeLayout...savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); swipeLayout...swipeLayout.setOnRefreshListener(this); swipeLayout.setColorScheme(android.R.color.holo_blue_bright...swipeLayout.setRefreshing(false); } }, 3000); } } xml实现activity_main.xml: <android.support.v4
= null) { isLoadMore = true; //设置在加载更多的时候swipeLayout不允许加载更多,同时需要设置在加载更多完毕的时候允许...swipeLayout加载更多 setRefreshEnabled(false); mLayoutManager.scrollToPosition(mLayoutManager.findLastVisibleItemPosition...为防止频繁网络请求,isLoadMore为false才可再次请求更多数据 */ private void setLoadMoreCompleted() { //因为在加载更多的时候设置swipeLayout...不允刷新, // 所以加载更多完毕的时候需要设置允许swipeLayout允许刷新 setRefreshEnabled(true); isLoadMore = false
如果你在想要刷新功能,在CoordinatorLayout外面套了一个SwipeRefreshLayout,一不小心就触发了刷新~~(自己体会) 解决方案:这个问题可以通过对AppBarLayout的监听,设置swipeLayout...mAblAppBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> { if (verticalOffset == 0) { swipeLayout.setEnabled...swipeLayout.isRefreshing()) { swipeLayout.setEnabled(false); } } }); 源码地址 Github
context=".MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeLayout...init(); //设置SwipeRefreshLayout mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout
com.iosdevlog.qiushibaike.MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeLayout...mRecyclerView = findViewById(R.id.recycleview) mSwipeRefreshLayout = findViewById(R.id.swipeLayout
写一个SwipeLayout 继承自 LineaLayout; 在构造时就创建好 DragHelper public SwipeItemLayout(Context context, @Nullable
领取专属 10元无门槛券
手把手带您无忧上云