Add swipe to refresh or pull to refresh in your sketchware project

How to add swipe to refresh or pull to refresh feature in your sketchware project ? 

Follow this below stepsTo enable swipe to refresh layout in your sketchware project.    

Step 1: enable required libraries :

Create a new project and enable  AppCompact and Design library

Note: Remember if you don’t enable this option your app will throw errors    

Step 2: Create the layout

Now drag and drop a Linear(H) with id  linear1 and make it’s height and width “match parent” and set padding to 0 Then add new webview with id webview1 inside the linear layout. 

Note :the ID of LinearLayout and webview must be linear1 and webview1. Otherwise you have to modify the code given by me in the step 4,step 5 and step 6 accordingly 

Step 3 : create variables

Create a new String variable called url

Step 4 : setup your events

Setup on create event

and add the following Webview1. Load url and add source directly block    

Add source directly code is

pl = new androidx.swiperefreshlayout.widget. SwipeRefreshLayout(this);linear1.removeAllViews();linear1.addView(pl);pl.addView(webview1);pl.setOnRefreshListener(new androidx.swiperefreshlayout.widget. SwipeRefreshLayout.OnRefreshListener(){@Override public void onRefresh(){webview1.loadUrl(url);}});

Webview on page started event:

Now at onPageStarted Write code     


Webview on page finished

And at onPageFinished write code    


Step 5: create a more block

Create a more block called refresh And define refresh. 

paste below code

}androidx.swiperefreshlayout.widget.SwipeRefreshLayout pl;{

And you are all set. Click run project to see the magic

Additional feature   Create a double tap to exit to your app.  

Leave a Reply