试图在网上浏览中发现页装上的进展情况。
这是我的主食法典。
namespace MauiApp2 {
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
void mywebview_Navigating(System.Object sender, Microsoft.Maui.Controls.WebNavigatingEventArgs e)
{
#if ANDROID
Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("Custom", (handler, view) =>
{
handler.PlatformView.Settings.CacheMode = Android.Webkit.CacheModes.Default;
handler.PlatformView.Settings.SetAppCacheEnabled(true);
handler.PlatformView.Settings.JavaScriptEnabled = true;
handler.PlatformView.SetWebChromeClient(new CustomWebViewClient(handler));
});
#endif
}
} }
and my CustomWebViewCLient.cs :
using Android.App;
using Android.Graphics;
using Android.Views;
using Android.Webkit;
using MauiApp2.Services;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebView = Android.Webkit.WebView;
namespace MauiApp2.Platforms.Android
{
public class CustomWebViewClient : MauiWebChromeClient
{
private readonly Activity context;
SpinnerPopup popup = new SpinnerPopup();
public CustomWebViewClient(IWebViewHandler handler) : base(handler)
{
this.context = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
}
public override void OnProgressChanged(WebView view, int newProgress)
{
Console.WriteLine(newProgress);
}
}
}
产出窗口没有显示什么,而网页却装满。