选择一项时,xamarin 自定义 ListView 不执行任何操作

xamarin custom ListView does nothing when one item is selected

public class ListViewFaixaAdapter : BaseAdapter<Model> {
    LayoutInflater _inflater;
    List<Model> _faixas;

    public ListViewFaixaAdapter(LayoutInflater inflater) : base(){
        _faixas = new List<Model>();
        for(int i = 0; i < 15; i++) {
            Model faixa = new Model();
            faixa.descricao = "Descrição " + i;
            faixa.letra = Convert.ToChar('A' + i).ToString() ;
            _faixas.Add(faixa);
        }
        _inflater = inflater;
    }

    public override Model this[int position] {
        get {
            return _faixas[position];
        }
    }

    public override int Count {
        get {
            return _faixas.Count;
        }
    }

    public override long GetItemId(int position) {
        return position;
    }

    public override View GetView(int position, View linhaView, ViewGroup parent) {
        var item = _faixas[position];            
        linhaView = linhaView ?? _inflater.Inflate(Resource.Layout.AuditoriaFaixaLinha, null);
        linhaView.Selected = false;   
        /* when uncomment something itens are click event duplicate
        linhaView.Click += (sender, e) => {
            //linhaView.Selected = !linhaView.Selected;
 /*((TextView)linhaView.FindViewWithTag("lblAuditoriaFaixaNota")).Selected = linhaView.Selected;
            ((TextView)linhaView.FindViewWithTag("lblAuditoriaFaixaLabel")).Selected = linhaView.Selected;
            ((TextView)linhaView.FindViewWithTag("lblAuditoriaFaixaDescricao")).Selected = linhaView.Selected;               

        };*/
        return linhaView;
    }
}
// using adapter
var listView = view.FindViewById<ListView>(Resource.Id.Item);
listView.Adapter = new ListViewFaixaAdapter(inflater);
listView.ItemClick += (sender, e) => {
    // do show when I clicked
    Toast.MakeText(Activity, "test", ToastLength.Short).Show();
};

显示 ListView 后,当我单击一个项目时,许多事件仅由一个项目触发。我没有在 xamarin.

上找到显示自定义 ListView 实现的完整示例

如果您的视图已经存在,您不应为其分配额外的事件处理程序

public override View GetView(int position, View linhaView, ViewGroup parent) {

    var item = _faixas[position];  

    if (linhaView == null) {
      linhaView = _inflater.Inflate(Resource.Layout.AuditoriaFaixaLinha, null);

      linhaView.Click += (sender, e) => {
        // handler code goes here...
      }
    }

    linhaView.Selected = false;   

    return linhaView;
}