Show TOC

MAFOptionMenuLocate this document in the navigation structure

The MAFOptionMenu control extends the capabilities of the optionmenu native Android control. MAF adds styling capabilities to the Optionmenu UI component. MAF supports skinning of tapped/untapped, and enabled/disabled visual states.

To create and present a default SAP style instance of MAFOptionMenu, use:
public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();                
        inflater.inflate(, menu);
        // Customize existing option menu. Must be called in 
        // method.                
        MAFUIFactory.getInstance().customizeOptionMenu(this, getResources());
        return true;

The MAF skinning engine customizes the optionmenus. To apply SAP style, set the custom style for background and foreground in the XML file.

This is the XAML content for the default style of the Optionmenu TargetType:
<Style TargetType="OptionMenu" platform="android">
                <VisualState Name="Unfocused_Enabled">                             
                       <Setter Property="Background" Value="#ff1b1b1b" />                             
                       <!-- background color -->                       
          <Setter Property="Foreground" Value="#ffa5a5a5" />
          <!-- text color -->
</ Style > 
MAFOptionMenu supports skinning of tapped/untapped, and enabled/disabled visual states. To set visual states, use the <VisualStates></VisualStates> tag:
<VisualState Name="Unfocused_Disabled">                             
       <Setter Property="Background" Value="fff0f0f0" />                             
       <!-- background color -->                       
<VisualState Name="Focused_Disabled">                             
       <Setter Property="Background" Value="#fff0f0f0" />                             
       <!-- background color -->                       
<VisualState Name="Focused_Enabled">                             
       <Setter Property="Background" Value="#ffb2e3f3" />                             
       <!-- background color -->                       
<VisualState Name="Pressed">                             
       <Setter Property="Background" Value="#ff0062a9" />                             
       <!-- background color -->                         
</ VisualState > 
You can change these properties in the skinning XML:
Background Color of the MAFOptionMenu’s background; can also be a freestyle gradient. Colors are defined as RGBA (red, green, blue, alpha).
Foreground Control's text color.