Widget - Webview Swipe Refresh

final android.support.v4.widget.SwipeRefreshLayout sr = new android.support.v4.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 = new WebView(this);
wb.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT));
wb.getSettings().setJavaScriptEnabled(true);
sr.addView(wb);
wb.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { sr.setRefreshing(false);
}});
wb.loadUrl("http://sketchware.io");
sr.setOnRefreshListener( new android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { wb.reload(); } } );

// add firebase and widget anyting from firebase


//Or you can use this mode edited


final android.support.v4.widget.SwipeRefreshLayout sr = new android.support.v4.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);
}});
wb.loadUrl("http://www.google.com");
sr.setOnRefreshListener( new android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { wb.reload(); } } );

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key