Android - 列表未绑定到 RecyclerView MvvmCross
Android - List not binding to RecyclerView MvvmCross
我是 android 的新手,我正在尝试将 ViewModel 中的列表绑定到 UI 中的 RecyclerView。我正在使用 Xamarin 和 MvvmCross。我有这样的 RecyclerView 设置:
<android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.Light">
<MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
android:id="@+id/navigation_recycler_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:clickable="true"
app:MvxItemTemplate="@layout/menu_item"
app:MvxBind="ItemsSource MyItems"/>
</LinearLayout>
这是我的菜单项:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
app:MvxBind="Text Title" />
</LinearLayout>
最后,我的虚拟机列表是这样的:
MyItems = new List<NavItem>
{
new NavItem { Title = "Option1" }
new NavItem { Title = "Option2" }
};
编辑:
这里是我设置属性的地方:
List<NavItem> _myItems;
public List<NavItem> MyItems
{
get => _myItems;
set => SetProperty(ref _myItems, value);
}
和我的项目:
public string Title { get; set; }
我很确定它的设置正确;但是,出于某种原因,它不会填充我的回收站视图。我错过了什么?任何帮助将不胜感激。谢谢!
想通了!我有 xmlns:app="https:
而不是 xmlns:app="http:
我是 android 的新手,我正在尝试将 ViewModel 中的列表绑定到 UI 中的 RecyclerView。我正在使用 Xamarin 和 MvvmCross。我有这样的 RecyclerView 设置:
<android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.Light">
<MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
android:id="@+id/navigation_recycler_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:clickable="true"
app:MvxItemTemplate="@layout/menu_item"
app:MvxBind="ItemsSource MyItems"/>
</LinearLayout>
这是我的菜单项:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
app:MvxBind="Text Title" />
</LinearLayout>
最后,我的虚拟机列表是这样的:
MyItems = new List<NavItem>
{
new NavItem { Title = "Option1" }
new NavItem { Title = "Option2" }
};
编辑:
这里是我设置属性的地方:
List<NavItem> _myItems;
public List<NavItem> MyItems
{
get => _myItems;
set => SetProperty(ref _myItems, value);
}
和我的项目:
public string Title { get; set; }
我很确定它的设置正确;但是,出于某种原因,它不会填充我的回收站视图。我错过了什么?任何帮助将不胜感激。谢谢!
想通了!我有 xmlns:app="https:
而不是 xmlns:app="http: