I'm trying use MvxListView
with MvxAppCompatActivity
, but I always get:
InflateException: Error inflating class Mvx.MvxListView ClassNotFoundException: Didn't find class "Mvx.MvxListView
Here is my axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.viniciusmaia.missaocarona"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/Toolbar" />
<Mvx.MvxListView
android:id="@+id/teste"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:MvxBind="ItemsSource Usuarios;ItemClick UsuarioClickCommand"
app:MvxItemTemplate="@layout/usuarioitem"/>
</LinearLayout>
Here is my Activity:
[Activity]
public class UsuarioActivity : MvxAppCompatActivity<UsuarioViewModel>
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.UsuarioView);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
toolbar.Title = UsuarioMensagens.TITULO_Usuario;
//SetSupportActionBar(toolbar);
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
ViewModel.Carregamento = new Carregamento(this);
ViewModel.PreenchePagina();
}
}
I tried use Mvx.MvxListview
and MvxListView
like this post Binary XML file line #1: Error inflating class Mvx.MvxListView, but nothing works for me.
Can anyone help me?
Try replacing this line on your LinearLayout
xmlns:app="http://schemas.android.com/apk/res/com.viniciusmaia.missaocarona"
with this:
Try writing
Mvx.MvxListView
in your axml file instead ofMvxListView
.Also your
xmlns:app="http://schemas.android.com/apk/res/com.viniciusmaia.missaocarona"
should be actuallyxmlns:app="http://schemas.android.com/apk/res-auto"
.One more thing to double check is to make sure your Setup class derives from MvxAndroidSetup
Mvx.MvxListView
mentioned in Alex's answer is a shortcut that is registered with the customInflater
that does binding in MvvmCross. This means, if yourSetup
class does not tell where to look forMvx
, the shortcuts wont work.In this case, I see you are using
MvxAppCompatActivity
, which comes from one of the Support packages. There is a separate Setup you inherit from there, which handles a lot of registration for you. It will also set up some tint aware views.So in your Setup, you should inherit from
MvxAppCompatSetup
:This should be enough to find
Mvx.MvxListView
. If it doesn't you can try adding more abbreviations by overridingViewNamespaceAbbreviations
in your Setup:This will make MvvmCross look for views in
MvvmCross.Binding.Droid.Views
when you prefix them withMvx
in your axml files."Mvx" => "MvvmCross.Binding.Droid.Views" is a default one, and should work with any
BindingInflater
from bothMvxAppCompatSetup
, but alsoMvxAndroidSetup
.