Issue
I need to add refreh page in my fragment, is it possible somehow? I'm not good familiar with java and I tryed to put code for refresh in public class.
It's my fragment.java file:
package com.example.bottomnavigationview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class Fragment1 extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment1,container,false);
View v = inflater.inflate(R.layout.fragment1,container,false);
WebView webView = (WebView)v.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.cybersport.ru/news");
return v;
}
Solution
The best solution is to just do webView.loadUrl( "javascript:window.location.reload( true )" );
. This should work on all versions and doesn't introduce new history entries.
Answered By - S_i_l_e_n_t C_o_d_e_r
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.