Unable to get listView.ItemClick to be called in MonoDroid

后端 未结 3 532
日久生厌
日久生厌 2020-12-20 06:07

I have the following code:

protected override void OnCreate (Bundle bundle)
{
    progress = ProgressDialog.Show(this, \"\", \"Loading...\");
    progress.Se         


        
3条回答
  •  旧巷少年郎
    2020-12-20 06:53

    I also managed to get though this problem by setting the "view.Click" handler inside the adapter::GetView function. Seems to work as well.

    public class TaskListAdapter : BaseAdapter {
        Activity context = null;
        IList tasks = new List();
    
        public TaskListAdapter (Activity context, IList tasks) : base ()
        {
            this.context = context;
            this.tasks = tasks;
        }
    
        [...]
    
        public override Android.Views.View GetView (int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
    
    
            var view = (convertView ??
                context.LayoutInflater.Inflate(...));
            view.FindViewById<..>(Resource.Id.NameText).SetText ("...", TextView.BufferType.Normal);
    
            view.Click += (sender, e) => 
            {
                int a=0;
                a++; //breakpoint location is being hit.
    
            };
            return view;
        }
    }
    }
    

提交回复
热议问题