我需要在我的片段中添加重繪 頁面,有可能嗎?我對java不太熟悉,我試圖將重繪 代碼放在公共類中。
這是我的 fragment.java 檔案:
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;
}
uj5u.com熱心網友回復:
最好的解決方案就是做webView.loadUrl( "javascript:window.location.reload( true )" );. 這應該適用于所有版本,并且不會引入新的歷史條目。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/468695.html
標籤:爪哇 安卓工作室 android-webview 刷新
