gpt4 book ai didi

android - 使用 Icommand 在 Listview 的 ListItem 中单击按钮

转载 作者:太空宇宙 更新时间:2023-11-03 11:06:51 24 4
gpt4 key购买 nike

我在 MvxListView 中有带有删除按钮的 Listitems。我想删除点击删除按钮的特定行。如何使用 Icommand 实现该点击事件?

最佳答案

扩展 MvxListView 使其具有 DeleteClick 属性:

ICommand DeleteClik;

将此属性绑定(bind)到您想要的命令:

local:MvxBind="DeleteClick MyDeleteCommand"

创建一个将引用此 DeleteClick 命令的自定义适配器,并将其绑定(bind)到 GetView 方法上的 View 点击事件:

public override View GetView (int position, View view, ViewGroup parent)
{
//TODO: Ensure view is not null, call base method and convert to proper type
var deleteButton = view.FindViewById<Button>(Resource.Id.buttonId);

deleteButton.Click += (sender, e) => {
if(_deleteCommand != null && _deleteCommand.CanExecute())
{
//TODO: Cast to your type
_deleteCommand(GetRawItem(position));
}
}
}

关于android - 使用 Icommand 在 Listview 的 ListItem 中单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31919735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com