GetView更新屏幕外项目

问题描述 投票:0回答:1

我有以下我的自定义适配器的GetView方法中的代码:

public override View GetView(int position, View convertView, ViewGroup parent)
    {
        var view = convertView ?? activity.LayoutInflater.Inflate(
                       Resource.Layout.ScannedTuListItem, parent, false);

        var scannedTu = view.FindViewById<TextView>(Resource.Id.scannedTu);

        var tuTxt = activity.Resources.GetString(Resource.String.tu);
        var custTxt = activity.Resources.GetString(Resource.String.customer);
        var orderTxt = activity.Resources.GetString(Resource.String.order);
        var targetBinTxt = activity.Resources.GetString(Resource.String.targetBin);

        scannedTu.Text = 
                        $"{tuTxt} {tus[position].No}" +
                        $"\n{custTxt} {tus[position].Customer} / {orderTxt} {tus[position].Order}" +
                        (string.IsNullOrEmpty(tus[position].TargetBin) ?
                        string.Empty : $"\n{targetBinTxt} {tus[position].TargetBin}");

        if (tus[position].AtPackingStation && !tus[position].Ready)
        {
            scannedTu.SetBackgroundColor(Color.Yellow);
            scannedTu.SetTextColor(Color.Black);
        }
        else if (tus[position].AtPackingStation && tus[position].Ready || tus[position].ScanOk == true)
        {
            scannedTu.SetBackgroundColor(Color.Green);
            scannedTu.SetTextColor(Color.Black);
        }
        else if (tus[position].ScanOk == false)
        {
            scannedTu.SetBackgroundColor(Color.Red);
            scannedTu.SetTextColor(Color.Black);
        }

        return view;
    }

当我改变物业qazxsw POI和POI qazxsw向qazxsw POI,比如说,在列表中的第3项,它会自动将项目的屏幕也给绿色以外的背景颜色。

我如何让它只上色第3项,而不会影响到屏幕的项目?

xamarin.android baseadapter notifydatasetchanged getview
1个回答
0
投票

当我改变物业ScanOK并准备为True,比方说,在列表中的第3项,它会自动将屏幕也给绿色以外的项目的背景颜色。

我如何让它只上色第3项,而不会影响到屏幕的项目?

对于你将不得不位置的基础上如添加一个初始条件

ScanOK

此外,如果你想有多少列表项的基础上,标注显示在屏幕上,你可以检查此Ready

© www.soinside.com 2019 - 2024. All rights reserved.