こんにちは私は、.net標準を使用してXamarinフォームポータブルプロジェクトに取り組んでいます。私は、アプリケーションのページにhtmlコンテンツをローカルにロードする必要があります。Forms.Contextは存在しません。xamarin froms HybridWebView
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Forms;
using AppName.Droid;
using Xamarin.Forms.Platform.Android;
using Android.Webkit;
using System.ComponentModel;
using AppName.Forms;
[assembly: ExportRenderer(typeof(HybridWebView), typeof(AppName.Droid.HybridWebViewRenderer))]
namespace AppName.Droid
{
public class HybridWebViewRenderer : ViewRenderer<HybridWebView, Android.Webkit.WebView>
{
const string JavaScriptFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}";
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (Control != null)
{
Control.Settings.BuiltInZoomControls = true;
Control.Settings.DisplayZoomControls = true;
}
base.OnElementPropertyChanged(sender, e);
}
protected override void OnElementChanged(ElementChangedEventArgs<HybridWebView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
// |
//Error is here \|/
var webView = new Android.Webkit.WebView(Forms.Context);
webView.Settings.JavaScriptEnabled = true;
SetNativeControl(webView);
Control.Settings.DomStorageEnabled = true;
}
if (e.OldElement != null)
{
Control.RemoveJavascriptInterface("jsBridge");
var hybridWebView = e.OldElement as HybridWebView;
hybridWebView.Cleanup();
}
if (e.NewElement != null)
{
Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
Control.LoadUrl(string.Format("file:///android_asset/Content/{0}", Element.Uri));
InjectJS(JavaScriptFunction);
}
}
void InjectJS(string script)
{
if (Control != null)
{
Control.LoadUrl(string.Format("javascript: {0}", script));
}
}
}
}
:
Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'Context' does not exist in the namespace 'AppName.Forms' (are you missing an assembly reference?)
Here's the example i'm going off of
ここで私は上のエラーを取得していたクラスがあります:私は、ビルドに失敗したAndroidデバイス上のアプリを実行し、私のにこのエラーを与えるために行くときどんな助けも素晴らしいだろう!
ありがとうございます!
に変更するAppName.Formsを使用していますか?あなたがどこかで "フォーム"をオーバーライドしているように見える –