【问题标题】:How to Change the Color of the Last item in ListView?如何更改 ListView 中最后一项的颜色?
【发布时间】:2015-03-29 22:16:12
【问题描述】:

我在 xamarin 中使用自定义列表和适配器如何更改列表视图中最后一项的颜色

这是我尝试过但没有奏效的方法

if (view.FindViewById<TextView> (Resource.Id.textView1).Text == "Add Profile") {
                view.FindViewById (Resource.Id.linearLayout1).SetBackgroundColor (Android.Graphics.Color.Aqua);
                Console.WriteLine ("LastItem");
            }

【问题讨论】:

    标签: xamarin xamarin.android


    【解决方案1】:

    您可以通过覆盖适配器类下的 GetView 方法来更改列表项视图的背景颜色。

    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        if(convertView == null)
        {
            convertView = LayoutInflater.From(this.context).Inflate('Your layout axml', parent, false);
        }
    
        convertView.SetBackgroundColor(Android.Graphics.Color.Aqua);
    
        return convertView;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-25
      • 2013-02-27
      • 2012-11-26
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 2014-10-25
      • 1970-01-01
      相关资源
      最近更新 更多