Changing listview colors

sevensakurasevensakura ✭✭Member ✭✭

Hello everyone, i have a problem with listview color, heres an example

i wanna make that grey like color (on steve list) gone when i am long tapping the list, can someone help me with it?
thank you

Tagged:

Answers

  • HarshitaHarshita ✭✭✭✭ INMember ✭✭✭✭
    @sevensakura
    you need to create a custom view cell renderer for that.and its very easy.
  • sevensakurasevensakura ✭✭ Member ✭✭

    @Harshita well, i asked here because i don,t know how to do that, i even didn't know what that color part named.

  • YorkGoYorkGo Xamurai CNMember, Xamarin Team Xamurai
    edited February 22

    i wanna make that grey like color (on steve list) gone when i am long tapping the list, can someone help me with it?

    Use custom ViewCell renderers:

    Android:

    public class CustomCellRenderer : ViewCellRenderer
        {
            protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
            {
                var cell = base.GetCellCore(item, convertView, parent, context);
    
                var listView = parent as Android.Widget.ListView;
    
                if (listView != null)
                {
                    listView.SetSelector(Android.Resource.Color.Transparent);
                    listView.CacheColorHint = Android.Graphics.Color.Transparent;
                }
    
                return cell;
            }
        }
    

    iOS:

    public class CustomCellRenderer: ViewCellRenderer
        {
            public override UIKit.UITableViewCell GetCell(Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
            {
                        tv.AllowsSelection = false;
                var cell = base.GetCell(item, reusableCell, tv);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
    
                return cell;
            }
        }
    
  • sevensakurasevensakura ✭✭ Member ✭✭
    edited February 25

    @YorkGo hello, thanks for your code. but i'm having problem cause some of them are getting error, like on

    protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
    

    xamarin cant find views, content, GetCellCore, cell, transparent and android.graphic.
    sorry if i miss something, i just started learning xamarin. thank you

  • YorkGoYorkGo Xamurai CNMember, Xamarin Team Xamurai

    Have a look at Xamarin custom-renderer

  • sevensakurasevensakura ✭✭ Member ✭✭

    okay i will try. thank you

Sign In or Register to comment.