In my Android activity, I create a custom view that extends SurfaceView (using MonoDroid so slight variations in syntax):
class FriendsView : SurfaceView
{
...
public FriendsView(Context context) : base(context)
{
... create my custom view ...
}
}
In my Activity class, I set the content view to the view:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
FriendsView friendsView = new FriendsView(this);
SetContentView(friendsView, layoutParams);
}
I want to add a button to the view, but cannot work out how to do this. Everything I have read starts from the point of view of the main.xml, but I don't see how to use this to declare a button which is visible in my view. Equally, I cannot find a method in either Activity or View classes which lets me add a Button object programatically.
I feel sure I am missing something conceptually, but would welcome any help to get me going in the right direction.