简体   繁体   中英

Visual studio, Xamarin, WebView

I'm making application for android using Visual Studio and Xamarin but I have problem with WebView when I create a WebView and try to see it in android emulator i get an error:

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

Anybody knows where is problem?

The Layout:

<?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>

After trying out the Layout xml the compiler throws an error becouse of a semicolon at the end of xmlns:android="schemas.android.com/apk/res/android"; . If you remove that the layout should build.

Another thing is that the url in xmlns:android attribute is missing http:// in front of the url. Without that the inflater doesn't understand the attributes correctly.

Here is a fixed Layout for you

<?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM