How can you change a Swipe refresh layout's color for each rotation?

前端 未结 5 2089
野的像风
野的像风 2021-02-03 19:19

Has anyone noticed the SwipeRefreshLayout in gmail. It changes color for every rotation in a single load iteration. Does anyone have any idea how to achieve it?

5条回答
  •  心在旅途
    2021-02-03 20:21

    swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.simpleSwipeRefreshLayout);
    
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
     {
                @Override
                public void onRefresh() {
    
                    // implement Handler to wait for 3 seconds and then update UI means update value of TextView
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            // cancle the Visual indication of a refresh
                            swipeRefreshLayout.setRefreshing(false);
                            swipeRefreshLayout.setColorSchemeResources(R.color.Aqua,R.color.Blue,R.color.Violet);
                            // Generate a random integer number
                            Random r = new Random();
                            int i1 = r.nextInt(80 - 65) + 65;
                            // set the number value in TextView
                            textView.setText(String.valueOf(i1));
                        }
                    }, 3000);
                }
            });
        }
    

提交回复
热议问题