We have a custom GridView
which has headerView
and footerView
properties. I'm wondering if in Android, it's possible to set those properties from within a layout file.
XAML in Windows lets you do this easily since you can specify properties either via attributes (for things like strings, numbers or other simple types), or via nested elements (for any object type) with a ControlType:PropertyName
syntax.
Here's a pseudo-version of what this would look like if Android supported something similar:
<MyCustomGrid
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- This would set the 'headerView' property
on 'MyCustomGrid' to a TextView -->
<MyCustomGrid:headerView>
<TextView android:text="I'm the Header TextView" />
</MyCustomGrid:headerView>
</MyCustomGrid>
Obviously the above is not valid. But is it possible to do something similar in Android, or do I have to do it in the code-behind in the Activity/Fragment?