Xamarin - 无法检测ListView ItemClick事件

时间:2017-04-05 18:39:20

标签: android listview xamarin xamarin.android

我想在ItemClick中获取ListView但无法检测到。我尝试在ClickListener的{​​{1}}方法中实施GetView(),并尝试BaseAdapter ItemClick。我没有取得任何成功。这是我的片段。

在此摘要片段中,我尝试在ListView

中实施ClickListener
GetView()

我也试过了ItemClick,这里也是一个片段。

public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = context.LayoutInflater.Inflate(Resource.Layout.single_row_listview_item, parent, false);

            ImageView photo = view.FindViewById<ImageView>(Resource.Id.photoImageView);
            TextView name = view.FindViewById<TextView>(Resource.Id.nameTextView);
            TextView speciality = view.FindViewById<TextView>(Resource.Id.specialtyTextView);

            Stream stream = context.Assets.Open(places[position].ImageUrl);
            Drawable drawable = Drawable.CreateFromStream(stream, null);
            photo.SetImageDrawable(drawable);

            name.Text = places[position].Name;
            speciality.Text = places[position].Specialty;

            name.Click += delegate
            {
                CommonUtils.showToast(context, "Click on name");
            };

            speciality.Click += delegate
            {
                CommonUtils.showToast(context, "Click on speciality");
            };

            photo.Click += delegate
            {
                CommonUtils.showToast(context, "Click on photo");
            };

            view.Click += delegate
            {
                CommonUtils.showToast(context, "Click on view");
            };



            return view;
        }

非常感谢任何帮助。

0 个答案:

没有答案