Version 01.02 of the ActionPack Released!

Posted on Oct 30, 2013

Appracatappra is proud to present the latest version of the ActionPack component suite for Xamarin Studio has been released.

Aside from several minor bug fixes, it adds new features to the ActionAlert. You can now attach a subview in place of the description text in the alert. Here is an example:

Custom Subview Alert

ActionAlert now supports attaching a custom subview to the alert in place of the description area. Here is an example of adding a text edit box to an alert:

iOS Example

// Build a custom view for this alert
UITextField field1 = new UITextField (new RectangleF (13, 41, 278, 29)) {
    BorderStyle = UITextBorderStyle.RoundedRect,
    TextColor = UIColor.DarkGray,
    Font = UIFont.SystemFontOfSize (14f),
    Placeholder = "Name",
    Text = "DefaultValue",
    BackgroundColor = UIColor.White,
    AutocorrectionType = UITextAutocorrectionType.No,
    KeyboardType = UIKeyboardType.Default,
    ReturnKeyType = UIReturnKeyType.Done,
    ClearButtonMode = UITextFieldViewMode.WhileEditing,
    Tag = 0,
    Enabled = true
};
field1.ShouldReturn = delegate (UITextField field){
    field.ResignFirstResponder ();
    return true;
};
field1.ShouldEndEditing= delegate (UITextField field){
    field.ResignFirstResponder ();
    return true;
};

// Create the new alert and attach the new field
_alert = new UIActionAlert (UIActionAlertType.Subview, UIActionAlertLocation.Middle, "Custom Subview", field1, "Cancel,OK");
_alert.Show ();

// Respond to any button being tapped
_alert.ButtonReleased += (button) => {
    field1.ResignFirstResponder ();
    _alert.Hide();
};

Android Example

// Create subview
var lp = new RelativeLayout.LayoutParams (278, 50);
var flp = new RelativeLayout.LayoutParams (278, 50);
var rl = new RelativeLayout (this);
var field1 = new EditText (this);

// Initialize subview
rl.LayoutParameters = lp;

// Initialize field and add to subview
flp.TopMargin = 0;
flp.RightMargin = 0;
field1.LayoutParameters = flp;
field1.Text = "Default Value";
rl.AddView (field1);

// Create alert
_alert = new UIActionAlert (this, UIActionAlertType.Subview, UIActionAlertLocation.Middle, "Custom Subview", rl, "Cancel,OK");
_alert.Show ();

// Respond to any button being tapped
_alert.ButtonReleased += (button) => {
    _alert.Hide();
};

Get your copy from the Xamarin Component Store here.