Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 试图将Html字符串放入Xamarin中的WebView_C#_Android_Xamarin_Webview - Fatal编程技术网

C# 试图将Html字符串放入Xamarin中的WebView

C# 试图将Html字符串放入Xamarin中的WebView,c#,android,xamarin,webview,C#,Android,Xamarin,Webview,我对Xamarin(Visual Studio 2017)中的WebView有点奇怪的问题 此方案有效: 我在“OnCreate”事件中将html内容放入webview,webview显示“Hello” 此场景不起作用: 我正在OnCreate中创建一个button控件并分配一个click事件。clickevent确实会启动,这样才能正常工作。但是“Hello2”并没有放到WebView中,尽管我使用了完全相同的代码 有什么问题吗 创建时受保护的覆盖无效(Bundle savedInstan

我对Xamarin(Visual Studio 2017)中的WebView有点奇怪的问题

此方案有效:
我在“OnCreate”事件中将html内容放入webview,webview显示“Hello”

此场景不起作用:
我正在OnCreate中创建一个button控件并分配一个click事件。clickevent确实会启动,这样才能正常工作。但是“Hello2”并没有放到WebView中,尽管我使用了完全相同的代码

有什么问题吗


创建时受保护的覆盖无效(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);Android.Content.Context Context=ApplicationContext;
Android.Support.V7.Widget.Toolbar-Toolbar=findviewbyd(Resource.Id.Toolbar);
设置支持操作栏(工具栏);
//它工作并显示:“你好”
WebView localWebView=findviewbyd(Resource.Id.localWebView);
localWebView.SetWebViewClient(新WebViewClient());//停止向Web浏览器发送请求
LoadData(“Hello”、“text/html”、“utf-8”);
按钮按钮=新按钮(上下文);
按钮。单击+=(发件人,参数)=>
{
//单击事件激发,但Hello2“未放入webview?
按钮btn=发送方为按钮;
WebView localWebView2=FindViewById(Resource.Id.LocalWebView);
localWebView2.SetWebViewClient(新WebViewClient());//停止向Web浏览器发送请求
localWebView2.LoadData(“Hello2”、“text/html”、“utf-8”);
};

}
当我将宽度和高度添加到WebView时,它现在起作用了。 奇怪的是,“填充父对象”或“匹配父对象”没有展开WebView