ListAdapter效率不高

时间:2016-03-27 17:21:21

标签: c# android xamarin

我为所有子适配器编写了这个父类,它与视图持有者一起使用,以确保应用程序顺利运行。

public override View GetView(int position, View convertView, ViewGroup parent)
{
   // Just a parent class
   GeneralViewHolder holder = null;

    try
    {
        _convertView = convertView;
        _parentView = parent;
        itemPosition = position;

        if (_convertView != null)
      {
          holder = _convertView.Tag as GeneralViewHolder;
      }
      else
      {
          _convertView = createView();
          holder = setupView();
          _convertView.Tag = holder;
      }
    }
    catch (Exception ex)
    {
        Console.WriteLine("GeneralAdapter ex: " + ex.Message);
    }
    populateHolder(holder);
    return _convertView;
}

/// <summary>
/// Inflates the layout.
/// </summary>
protected virtual View createView()
{
    throw new NotImplementedException();
}

/// <summary>
/// Sets up the view holder.
/// </summary>
protected virtual GeneralViewHolder setupView()
{
    throw new NotImplementedException();
}

/// <summary>
/// Will load data into the viewholder.
/// </summary>
protected virtual GeneralViewHolder populateHolder(GeneralViewHolder _holder)
{
    throw new NotImplementedException();
}

据我所知,这应该是ListViews的视图持有者模型。 但不知何故,这并不顺利。

你知道为什么吗?

0 个答案:

没有答案