我使用Xamarin.Native做了一个Android应用。它工作正常,但它有一个问题。当我点击任何链接时,它不会在屏幕上显示任何内容以显示它正在加载下一页。有什么想法吗?
namespace name
{
[Activity(Label = "name", MainLauncher = true, Theme = "@android:style/Theme.NoTitleBar")]
public class MainActivity : Activity
{
WebView web_view;
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
web_view = FindViewById<WebView>(Resource.Id.webview);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadUrl("http://mimabebes.es");
web_view.SetWebViewClient(new WebViewClient());
}
public override bool OnKeyDown(Android.Views.Keycode keyCode, Android.Views.KeyEvent e)
{
if (keyCode == Android.Views.Keycode.Back && web_view.CanGoBack())
{
web_view.GoBack();
return true;
}
return base.OnKeyDown(keyCode, e);
}
}
}
答案 0 :(得分:0)
有两种覆盖方法:
OnPageStarted
OnPageFinished
您可以编写代码以在OnPageStarted
中显示进度条,并隐藏OnPageFinished
方法中的进度。
public override void OnPageStarted(WebView view, string url, Android.Graphics.Bitmap favicon)
{
base.OnPageStarted(view, url, favicon);
// Code to show the progress bar
}
public override void OnPageFinished(WebView view, string url)
{
base.OnPageFinished(view, url);
// Code to hide the progress bar
}