【问题标题】:Visual studio, Xamarin, WebView视觉工作室、Xamarin、WebView
【发布时间】:2015-01-30 18:18:26
【问题描述】:

我正在使用 Visual Studio 和 Xamarin 为 android 制作应用程序,但是当我创建 WebView 并尝试在 android 模拟器中查看它时出现 WebView 问题,我收到错误:

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.webkit.WebView

有人知道问题出在哪里吗?

布局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="schemas.android.com/apk/res/android";    
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:minWidth="25px" 
    android:minHeight="25px"> 

    <WebView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/webView1" /> 
</LinearLayout>

【问题讨论】:

  • 请包含包含 WebView 的 Activity 的布局文件 (XML)。非常感谢您为使布局膨胀的活动的代码。
  • @arnfada 嗨,我创建了一个简单的 WebView 来进行测试,同样的错误出现在这里是他的 xml 代码:schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minWidth="25px" android:minHeight="25px">
  • 首先,xmlns:android="schemas.android.com/apk/res/android"; 末尾有一个不应该存在的分号。现在,当您运行项目时。完整的错误描述是什么? @Yupi
  • @arnfada 我不小心输入了分号,我的项目中没有,我不知道我可以在这里输入图片,但我做了一个错误截图,你可以在我的保管箱上查看它是链接:dropbox.com/s/xkjitv7kra3zz0v/Error.png?dl=0 请注意,我在 xml 和 c# 中从 webWiew 中删除了数字 1,因此您不会对此感到困惑!因为图片中的 webView 没有数字 1。感谢您的帮助

标签: c# android xamarin


【解决方案1】:

在尝试了 Layout xml 之后,编译器会因为xmlns:android="schemas.android.com/apk/res/android"; 末尾的分号而引发错误。如果您删除该布局应该构建。

另一件事是xmlns:android属性中的url在url前面缺少http://。否则,inflater 无法正确理解属性。

这是给你的固定布局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:minWidth="25px" 
    android:minHeight="25px"> 

    <WebView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/webView1" /> 
</LinearLayout>

【讨论】:

  • 不,同样的错误出现。 :/ 你在我之前的评论中有错误的图片
  • 除非您向我提供实际的 xml 布局和实际代码,否则我无能为力。
  • @Yupi,你用的是什么模拟器?
  • 我复制了您输入的代码并粘贴,但它不起作用,总是一样的东西。我认为问题不在代码中!银河 Nexus 安卓 5.0。 1.API 21,我尝试更改API级别和模拟器,但同样的事情,我认为我唯一能做的就是尝试重新安装Visual Studio
猜你喜欢
  • 2016-01-19
  • 1970-01-01
  • 2018-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多