How to use the SwipeRefreshLayout?

后端 未结 5 1896
孤独总比滥情好
孤独总比滥情好 2020-12-25 11:51

Background

Google has recently published an update to its support library, which now has a new \"SwipeRefreshLayout\" view.

The view allows to wrap anothe

5条回答
  •  甜味超标
    2020-12-25 12:16

    You can by simply following below method (I am using swipelayout on Expandable list ) Test.xml

      
    
            
        
    

    ListHeader.xml

        
        
    
    
    
    
    

    ChildItem.xml

    
    
    
    
    
    
    
    
    
    

    colors used

    #8ec549
    #c1f57f
    #f7ffed
    #d6d4d4
    

    Mainactivity.java

            swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe2);
            swipeView.setColorSchemeResources(R.color.pDarkGreen, R.color.Gray, R.color.Yellow, R.color.pFullLightGreen);
    
    swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
    
                            swipeView.setRefreshing(false);
    
                        }
                        (new Handler()).postDelayed(new Runnable() {
                            @Override
                            public void run() {
    
                                Log.d("Swipe", "Refreshing Number");
    
                            }
                        }, 0);
                    }
                });
    

    You can set swipeView.setRefreshing(false); to false or true according to your requirment this swipeing mechanisam will work in android's all API level

提交回复
热议问题