- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的 Xamarin.iOS 项目中有一个 CollectionView。我的 UICollectionViewCell 中有一个按钮,我想在我的按钮上设置 TouchDown。
但是当我点击这个按钮时,触发了 ItemSelected 而不是我的 TouchDown 事件处理程序(调用单元格上的全局触摸而不是特定触摸)。
你能帮我如何在任何单元格内指定我的触摸吗? (对不起,我的英语不是最好的)
这是我的代码:
class MyCollectionViewSource : UICollectionViewSource
{
List<string> _Datas;
public MyCollectionViewSource(List<string> datas)
{
_Datas = datas;
}
public override nint GetItemsCount(UICollectionView collectionView, nint section)
{
return _Datas.Count;
}
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
{
var view = (MyCollectionViewCell)collectionView.DequeueReusableCell(MyCollectionViewCell.CellId, indexPath);
return view;
}
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
{
Console.WriteLine("Row {0} selected", indexPath.Row);
}
public override bool ShouldSelectItem(UICollectionView collectionView, NSIndexPath indexPath)
{
return true;
}
}
class MyCollectionViewCell : UICollectionViewCell
{
UIView _MyCellView;
public static readonly NSString CellId = new NSString("MyCollectionViewCell");
[Export("initWithFrame:")]
MyCollectionViewCell(RectangleF frame) : base(frame)
{
_MyCellView = new UIView();
ContentView.AddSubview(_MyCellView);
UIButton btn = new UIButton();
btn.SetTitle("test", UIControlState.Normal);
btn.Frame = new CoreGraphics.CGRect(0, 0, 100, 20);
btn.TouchDown += Btn_TouchDown;
_MyCellView.AddSubview(btn);
}
private void Btn_TouchDown(object sender, EventArgs e)
{
}
}
最佳答案
如果要设置Button
的点击事件。事件名称为
btn.TouchUpInside += Btn_TouchUpInside;
事件 TouchDown
将在您点击按钮但未收回手指时调用。
关于c# - 单击未调用的 UICollectionViewCell 中的特定元素(而不是从源中触发的 ItemSelected)Xamarin.ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57623781/
Case_history_review.java public class Case_history_review extends AppCompatActivity { private Drawe
我的应用程序中有一个带有 setOnItemSelectedListener 的微调器控件,当我选择微调器的一个项目时,将启动事件 onItemSelected。现在我希望点击一个按钮来启动 onIt
This is for Xamarin.iOS Sorry for confusion this is not for Objective-C but for C# Xamarin.iOS , I a
我对 Xamarin.Form 非常陌生,非常感谢您的帮助。 我正在为我当前的项目使用 MVVM 模式。我的 ListView 中填充了人员,我想在 ListView 中选择项目并显示详细信息。不幸的
我有一个关于 ListView 元素上的 ItemSelected() 事件的问题。 我的 ListView 基于这样的 DataTemplate:
我有一个 ListView ,当单击列表项时,我想打开项目详细信息页面。但是当我快速单击不止一次时,它会打开两个导航页面。我的详细信息页面的 const 有一个异步方法。这是我的代码。 如何阻止多次点
我已经创建了一个简单的 MultiSelectListView 如下所示,但是不知何故 ItemSelected 事件没有被触发。 谁能告诉我,哪里出了问题,因为我想我已经尝试了一切? using S
我有一个 Intent 启动的 Activity ,页面上有许多微调器。我刚刚在 this 之后设置了微调器的 ItemSelected 监听器指导。问题是,每个 Spinner 中的第一个项目基本上
我正在尝试为我正在开发的社交应用程序开发一个注册菜单。我希望注册菜单包含一个包含五个 fragment 的 PageViewer。最后三个 fragment 包含一个 ListView,用户可以在其中
我有一个绑定(bind)到对象树的 TreeView 。当我从对象树中删除对象时,它会从 TreeView 中正确删除,但 TreeView 的默认行为是将所选项目向上跳转到已删除项目的父节点。我怎样
我有一个 UICollectionViewController 定义如下: [] type LandlordHome (handle:IntPtr) = inherit UIColle
所以我正在试用 Xamarin Forms,我制作了一个控件,它有一个输出 UICollectionView 的渲染器。有问题的 Collection View 是从 Objective C 版本移植
我需要在更改文本框时触发 ajax 更新,这是一个 成分。我观察到,如果用户选择手动键入文本,则事件是更改,而如果用户单击自动完成建议之一,则事件是 itemSelect。所以我加了两个 输入的子项,
我想问一下 RxSwift。 当我想在 RxSwift 中使用 tableView 委托(delegate)函数时遇到问题 我不知道问题的根源.. 问题是当我使用 rx.ItemSelected 在单
我正在开发一个平板电脑应用程序,主要 Activity 有两个 fragment 。左侧 fragment 是一个列表 fragment ,当用户选择一个选项卡或从 ActionBar 中的 2 个微
我是 Xamarin 和 Android 编程的新手。 我对 Spinner 小部件有疑问。当嵌入到 AXML 文件中时,它过去可以像普通小部件一样正常工作。 现在我需要在运行时动态创建和显示它,我调
我想从 tableView.rx.itemSelected 获取对象并对其进行处理。此方法返回 IndexPath,因此我可以映射此值。但是如何从 ViewModel 获取索引处的对象呢? struc
我有一个带有一些值的微调器,我从我的网络服务中填充它。 填充微调器 int i = 0; var dropItems = new List(); DataRow[] result = myOPTval
我的 Xamarin.iOS 项目中有一个 CollectionView。我的 UICollectionViewCell 中有一个按钮,我想在我的按钮上设置 TouchDown。 但是当我点击这个按钮
我正在使用 Primefaces 3.4.2 自动完成。 在 ManagedBean 中,当我在自动完成中键入字符时选择一行时,我无法在方法 handleSelect(SelectEvent even
我是一名优秀的程序员,十分优秀!