{"id":1885,"date":"2022-08-30T15:20:15","date_gmt":"2022-08-30T15:20:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/mvvmcross-android-error-inflating-class-mvx-mvxbindablelistview-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:15","modified_gmt":"2022-08-30T15:20:15","slug":"mvvmcross-android-error-inflating-class-mvx-mvxbindablelistview-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/mvvmcross-android-error-inflating-class-mvx-mvxbindablelistview-collection-of-common-programming-errors\/","title":{"rendered":"MvvmCross Android &#8211; Error Inflating class Mvx.MvxBindableListView-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m having trouble using an activity with MvvmCross in Mono for Android. Basically, the app compiles, and runs, but I get an unhandled exception when I call SetContentView:<\/p>\n<p>&#8220;Android.Views.InflateException: Binary XML file line #1: Error inflating class Mvx.MvxBindableListView&#8221;<\/p>\n<p>In the stack trace it mentions the class not found was the cause.<\/p>\n<p>Here&#8217;s my Activity:<\/p>\n<pre><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nusing Android.App;\nusing Android.Content;\nusing Android.OS;\nusing Android.Runtime;\nusing Android.Views;\nusing Android.Widget;\nusing Cirrious.MvvmCross.Droid.Views;\nusing WshLst.Core.ViewModels;\nusing WshLst.Core.Models;\n\nnamespace WshLst.MonoForAndroid.Views\n{\n    [Activity(Label = \"Wsh Lst - Login\")]\n    public class LoginView : MvxActivityView\n    {\n        ListView list;\n\n        protected override void OnViewModelSet()\n        {\n            RequestWindowFeature(WindowFeatures.ActionBar);\n\n            SetContentView(Resource.Layout.Page_LoginView);\n\n            list = this.FindViewById(Resource.Id.mvxList);\n\n            list.ItemClick += (s, e) =&gt;\n            {\n                var item = list.Adapter.GetItem(e.Position);\n\n                var castItem = (Cirrious.MvvmCross.Binding.Droid.MvxJavaContainer)item;\n\n                this.ViewModel.Login((WshLst.Core.Models.LoginPlatform)castItem.Object);\n            };\n        }\n    }\n}\n<\/code><\/pre>\n<ol>\n<li>\n<p>Your activity needs to inherit from <code>MvxBindingActivityView<\/code> instead of <code>MvxActivityView<\/code><\/p>\n<h2>The back story<\/h2>\n<p>MvvmCross is built in layers and modules:<\/p>\n<ul>\n<li>Cirrious.MvvmCross &#8211; just gives the core INotifyPropertyChanged and navigation<\/li>\n<li>Cirrious.MvvmCross.Binding &#8211; gives you data-binding for Droid and Touch<\/li>\n<li>Cirrious.MvvmCross.Dialog &#8211; gives you monotouch\/droid\/<em>soon more<\/em> Dialog helpers<\/li>\n<li>Cirrious.MvvmCross.AutoViews &#8211; this might one day give you automatic default UI views<\/li>\n<li>Plugins &#8211; each plugin gives you specific functionality &#8211; e.g. SQLite<\/li>\n<\/ul>\n<p>The idea is to try to provide a &#8220;light&#8221; core framework for those who just want the bare minimum, but to provide a more sophisticated framework for those who want more.<\/p>\n<p>This does have the downside that some of the names can get confusing&#8230; that there are more dll&#8217;s to reference&#8230; and that users can occasionally inherit from the wrong level object &#8211; which is what your problem was here:<\/p>\n<ul>\n<li>you were inheriting from <code>MvxActivityView<\/code> which has a <code>ViewModel<\/code><\/li>\n<li>but not from <code>MvxBindingActivityView<\/code> which has binding support as well.<\/li>\n<\/ul>\n<p>There&#8217;s a little more info on what&#8217;s in the 2 layers at Insert a Monogame view inside MvvmCross monodroid Activity<\/p>\n<\/li>\n<li>\n<p>New cause: the MvxBindableListView is renamed to MvxListView. But the above is confusing by now. Because I was inheriting from MvxFragment I thought this was the cause and was trying to understand and implement what Stuart wrote &#8230; Then I remembered something about renaming classes and then it was quickly found \ud83d\ude42<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-02 21:11:17. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m having trouble using an activity with MvvmCross in Mono for Android. Basically, the app compiles, and runs, but I get an unhandled exception when I call SetContentView: &#8220;Android.Views.InflateException: Binary XML file line #1: Error inflating class Mvx.MvxBindableListView&#8221; In the stack trace it mentions the class not found was the cause. Here&#8217;s my Activity: using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1885","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1885"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1885\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}