Xamarin mutli选择列表视图 [英] xamarin mutli selection listview

查看:106
本文介绍了Xamarin mutli选择列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在设法解决我的问题,但我没有找到它,所以我在寻找您的帮助.

It's been a while that i'm trying to get an anwser to my problem, but i didn't find it... So i'm searching for your help.

我在xamarin上工作以制作一个android应用程序,但我不使用Xamarin.Forms(如果我在开始项目时知道的话,我会用它的.

I work on xamarin to make an android application but i dont use Xamarin.Forms (i would have used it, if i knew it when i begin the project

如果您有任何疑问,我会直接问我.

I'll directly to the point, if you have some question, just ask me.

所以我有一个Listview,可以在其中选择2个或更多项目:

So i got a Listview where i can select 2 or more items :

private void _listViewIntervention_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
    {
        _intervention[e.Position].IsSelected = !_intervention[e.Position].IsSelected;
        if (_intervention[e.Position].IsSelected)
            e.View.SetBackgroundColor(Android.Graphics.Color.Rgb(255, 127, 127));
        else
            e.View.SetBackgroundColor(Android.Graphics.Color.Rgb(230, 230, 230));

        _numberInterventionSelected.Text = _intervention.FindAll(elem => elem.IsSelected == true).Count().ToString();
    }

那东西可以工作,但是如果我有一个包含20个项目的列表视图,即我选择了3个项目,那么如果我滚动列表视图,一切都会受到干扰,我的3个突出显示的行将不再存在,并且突出显示将在另一行我从来没有选择.

That thing work but if i have a listview with 20 items i.e and i select 3 items, if i scroll the listview, everything will be disturb and my 3 highlighted rows won't be anymore and the highlight will be on another row that i've never select.

我认为那不是很明显,可能是模糊的.

I think that not that evident and it might be blur.

IMO,当我执行"e.View.SetBackgroundColor"时,我并没有改变好事,但我尝试了很多没用的事. 我可能并没有采取最好的方式做我想做的事.

IMO i'm not changing the good thing when i do the "e.View.SetBackgroundColor" but i've try lot of thing that never worked. I might not going the best way to do what i want to do btw.

我想要的结果是当我滚动列表视图时,没有任何变化,因此我可以选择列表视图的第一项和最后一项.

The result i want is when i scroll the listview, nothing change so i can select the first and the last item of the listview i.e.

我再次在自己身边搜寻,但我对您有所了解... 感谢您的阅读,祝您有美好的一天!

I search again in my side but i count a little on you know... Thanks for reading and have a good day !

推荐答案

经过大量搜索并找到解决方案后,我已经遇到了同样的问题

I have already getting same problem after lot of search and find the solution

在Xamarin自定义适配器中,删除ViewHolder System后,删除Holder系统即可正常工作

In Xamarin custom adapter remove ViewHolder System it's working fine after removing Holder system

这篇关于Xamarin mutli选择列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆