但是使用26.1.0版本时,SwipeRefreshLayout控件刷新后快速点击无效,需要等一段时间才能点击栏目。
这个问题只在荣耀9和nova手机上发现了,其他手机正常。
这是响应处代码
- srl_refresh_tool.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- srl_refresh_tool.postDelayed(new Runnable() {
- @Override
- public void run() {
- srl_refresh_tool.setRefreshing(false);
- }
- }, 500);
- }
- });
- public class MyRecyclerView extends RecyclerView {
- public MyRecyclerView(Context context) {
- super(context);
- }
- public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- }
- public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
- @Override
- public boolean onInterceptTouchEvent(MotionEvent event) {
- boolean requestCancelDisallowInterceptTouchEvent = getScrollState() == SCROLL_STATE_SETTLING;
- boolean consumed = super.onInterceptTouchEvent(event);
- final int action = event.getActionMasked();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- if( requestCancelDisallowInterceptTouchEvent ){
- getParent().requestDisallowInterceptTouchEvent(false);
- // only if it touched the top or the bottom. Thanks to @Sergey's answer.
- if (!canScrollVertically(-1) || !canScrollVertically(1)) {
- // stop scroll to enable child view to get the touch event
- stopScroll();
- // do not consume the event
- return false;
- }
- }
- break;
- }
- return consumed;
- }
- }





































苏公安网备 32011402010933号