Reputation: 347
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?
Upvotes: 0
Views: 671
Reputation: 24460
Mvx.MvxListView
mentioned in Alex's answer is a shortcut that is registered with the custom Inflater
that does binding in MvvmCross. This means, if your Setup
class does not tell where to look for Mvx
, 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
:
public class Setup : MvxAppCompatSetup
{
}
This should be enough to find Mvx.MvxListView
. If it doesn't you can try adding more abbreviations by overriding ViewNamespaceAbbreviations
in your Setup:
public class Setup : MvxAppCompatSetup
{
...
protected override IDictionary<string, string> ViewNamespaceAbbreviations new Dictionary<string, string>
{
{"Mvx", "MvvmCross.Binding.Droid.Views"},
{"MyViews", "My.Custom.Views"},
// add more abbreviations here
};
}
This will make MvvmCross look for views in MvvmCross.Binding.Droid.Views
when you prefix them with Mvx
in your axml files.
"Mvx" => "MvvmCross.Binding.Droid.Views" is a default one, and should work with any BindingInflater
from both MvxAppCompatSetup
, but also MvxAndroidSetup
.
Upvotes: 4
Reputation: 4632
Try replacing this line on your LinearLayout
xmlns:app="http://schemas.android.com/apk/res/com.viniciusmaia.missaocarona"
with this:
xmlns:app="http://schemas.android.com/apk/res-auto"
Upvotes: 0
Reputation: 3101
Try writing Mvx.MvxListView
in your axml file instead of MvxListView
.
Also your xmlns:app="http://schemas.android.com/apk/res/com.viniciusmaia.missaocarona"
should be actually xmlns:app="http://schemas.android.com/apk/res-auto"
.
One more thing to double check is to make sure your Setup class derives from MvxAndroidSetup
Upvotes: 0