我花了整整两天的时间来弄清楚如何将数据和命令绑定到诸如按钮或listView之类的布局元素上,直到现在为止,我一直没有成功,以下是我作为一个例子的例子布局。
您能帮我吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srlStores"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="80"
local:MvxBind="Refreshing IsBusy">
<MvxListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lvStores"
local:MvxBind="ItemsSource Stores; ItemClick OpenDetailCommand"
local:MvxItemTemplate="@layout/store_list_item" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="20"
android:id="@+id/progressBar1"
local:MvxBind="Visible IsBusy" />
<Button
android:text="@string/storeListCreateButtonText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bCreate"
android:layout_weight="20"
local:MvxBind="Click CreateCommand" />
</LinearLayout>
欢迎使用堆栈溢出!你非常亲密。您必须确保正确设置了ViewModel,然后进入与该Layout所属的Fragment关联的ViewModel,并为按钮添加以下内容: