Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Preventing ViewCell From Getting Focus on Android

$
0
0

Hello,

I can disable the selection of a list view item on iOS by using an override for the ViewCellRenderer similar to:

    public override UITableViewCell GetCell(
        Cell item,
        UITableViewCell reusableCell,
        UITableView tv)
    {
        UITableViewCell cell = base.GetCell(item, reusableCell, tv);
        CustomViewCell customViewCell = (CustomViewCell)item;

        cell.SelectionStyle = (customViewCell.ShowSelection)
            ? (UITableViewCellSelectionStyle.Default)
            : (UITableViewCellSelectionStyle.None);

        return cell;
    }

I would like to disable the selection for a listview item on Android as well. I tried the following, but it does not seem to work:

    protected override Android.Views.View GetCellCore(
        Cell item, 
        Android.Views.View convertView, 
        Android.Views.ViewGroup parent, 
        Android.Content.Context context)
    {
        Android.Views.View cell = base.GetCellCore(item, convertView, parent, context);
        CustomViewCell customViewCell = (CustomViewCell)item;

        cell.Focusable = false;

        return cell;
    }

Any thoughts? Thank you!


Viewing all articles
Browse latest Browse all 77050

Trending Articles