如何迭代 ListView 并使用 MvvmCross 获取项目
How to iterate ListView and get item using MvvmCross
使用webservice从后端获取数据后,如何迭代ListView并从中逐项获取项目在用户更改或编辑Edittext后。
<LinearLayout>
<MvxListView
android:id="@+id/ls_contact"
android:MvxItemTemplate="@layout/Item_Contact_List"
local:MvxBind="ItemsSource PPL" />
<Button
android:id="@+id/btnSubmit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Submit"/>
</LinearLayout>
Item_Contact_List.axml:
<LinearLayout>
<TextView
android:id="@+id/tv_name"
local:MvxBind="Text Name" />
<EditText
android:id="@+id/tv_contactno"
local:MvxBind="Text ContactNo" />
</LinearLayou
----------- In ViewModel
1. Use the webservice to get the data from BackEnd
in ViewModel :
OnCreate()
{
_ppl = WebSvc.getContact() //-- this is webservice
}
private People _ppl = new People();
public People PPL
{
get { return this._ppl; }
set {
this._ppl = value;
this.RaisePropertyChanged(() => this.PPL);
}
}
2. When user click the Submit button
Question :
How to iterate the ListView and to get the tv_name and tv_contactno
谢谢。感谢您的帮助。
AFAIK,列表 PPL
将包含更改的项目...直接对绑定列表进行绑定。如果你在提交
时迭代抛出你的 PPL
属性 你应该看到这个
使用webservice从后端获取数据后,如何迭代ListView并从中逐项获取项目在用户更改或编辑Edittext后。
<LinearLayout>
<MvxListView
android:id="@+id/ls_contact"
android:MvxItemTemplate="@layout/Item_Contact_List"
local:MvxBind="ItemsSource PPL" />
<Button
android:id="@+id/btnSubmit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Submit"/>
</LinearLayout>
Item_Contact_List.axml:
<LinearLayout>
<TextView
android:id="@+id/tv_name"
local:MvxBind="Text Name" />
<EditText
android:id="@+id/tv_contactno"
local:MvxBind="Text ContactNo" />
</LinearLayou
----------- In ViewModel
1. Use the webservice to get the data from BackEnd
in ViewModel :
OnCreate()
{
_ppl = WebSvc.getContact() //-- this is webservice
}
private People _ppl = new People();
public People PPL
{
get { return this._ppl; }
set {
this._ppl = value;
this.RaisePropertyChanged(() => this.PPL);
}
}
2. When user click the Submit button
Question :
How to iterate the ListView and to get the tv_name and tv_contactno
谢谢。感谢您的帮助。
AFAIK,列表 PPL
将包含更改的项目...直接对绑定列表进行绑定。如果你在提交
PPL
属性 你应该看到这个