How to create Swipe to Refresh in Sketchware using Androidx

The code used is:

final androidx.swiperefreshlayout.widget.SwipeRefreshLayout
 sr = new androidx.swiperefreshlayout.widget.SwipeRefreshLayout
(this); sr.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT));
linear1.addView(sr); final WebView wb = (WebView)findViewById(R.id.webview1); wb.getSettings().setJavaScriptEnabled(true); linear1.removeView(wb); linear1.post(new Runnable() { @Override public void run() { sr.addView(wb); } }); wb.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { sr.setRefreshing(false); }}); sr.setOnRefreshListener( new androidx.swiperefreshlayout.widget.SwipeRefreshLayout
.OnRefreshListener() { @Override public void onRefresh() { wb.reload(); } } );

The tutorial video related to it:


Comments

Popular posts from this blog

How to Create Material Ripple Effect in Sketchware

How to Create Custom Notifications with Listeners

How to create Custom Dialog in Sketchware