SortableTableView icon indicating copy to clipboard operation
SortableTableView copied to clipboard

CheckBox to TableHeaderAdapter

Open IranthaJ opened this issue 4 years ago • 1 comments

I am using this table view and trying to create a table with a header checkbox and checkbox for each row. Something like below; image

I was able to render checkboxes in rows but could not find a way to set it in the header with 'SimpleTableHeaderAdapter'. Is there a way to include views in the header?

I only see these constructors;

public SimpleTableHeaderAdapter(Context context, params string[] headers);
public SimpleTableHeaderAdapter(Context context, params int[] headerStringResources);

Note: I am working with Xamarin C# - https://github.com/xamarin/XamarinComponents/tree/master/Android/SortableTableView

IranthaJ avatar May 08 '20 02:05 IranthaJ

I got to know that we can use customized TableHeaderAdapter as our Data adapter. I was successful with the following example

public class CustomTableHeaderAdapter : TableHeaderAdapter 
{
    public CustomTableHeaderAdapter(Context context)
    {
        super(context);
    }
   public override View GetHeaderView(int columnIndex, ViewGroup parentView)
   {
        switch( columnIndex ) 
        {
            case 0: return RenderCheckBox();
            case 1: return RenderTextCell( "Column header");
            default: return null;
        }
    }
        private View RenderTextCell(string text)
        {
            var textView = new TextView(this.Context);
            textView.Text = text;
            return textView;
        }
        private View RenderCheckBox()
        {
            CheckBox checkBox = new CheckBox(this.Context);
            checkBox.Click += HeaderCheckBox_Click;
            return checkBox;
        }
}

IranthaJ avatar May 13 '20 07:05 IranthaJ