简体   繁体   中英

How to include a .xaml script inside of a .xml file in Xamarin?

I'm working on an Android App inside of Visual Studio and using Xamarin. I've created a .xmal file which serves as a footer and I am trying to implement it inside of my main .xml script like this:

<ArchaismDictionaryAndroidApp.Resources.layout.footer
    android:layout_width = "match_parent"
    android:layout_height = "100dp"
    android:layout_alignParentBottom = "true"
    android:largeHeap="true"/>

The tag is the namespace.class of the C# script which comes with the .xaml file. When I try to run my app, though, I get this error message:

Android.Views.InflateException: 'Binary XML file line #2: Binary XML file line #2: Error inflating class ArchaismDictionaryAndroidApp.Resources.layout.footer'

I get it on this line of code: SetContentView(Resource.Layout.activity_main); What are some of the probable causes for this problem? Thank you in advance.

Strictly speaking you can't. However you can add a fragment to your xml file and then convert XAML to fragment using the code and assign to it.

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