Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckBox to TableHeaderAdapter #195

Open
IranthaJ opened this issue May 8, 2020 · 1 comment
Open

CheckBox to TableHeaderAdapter #195

IranthaJ opened this issue May 8, 2020 · 1 comment

Comments

@IranthaJ
Copy link

IranthaJ commented May 8, 2020

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
Copy link
Author

IranthaJ commented May 13, 2020

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 IranthaJ changed the title CheckBox to SimpleTableHeaderAdapter CheckBox to TableHeaderAdapter May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant