The MAFSearchBox control extends the capabilities of the android.widget.EditText native control. MAF adds styling capabilities to the EditText UI component. You can also use MAFSearchBox as a password input field, or a mandatory input field.
MAFSearchBox searchBox = new MAFSearchBox(this); searchBox.setOnSearchListener(mafOnSearchListener)
Use mafOnSearchListener to obtain the entered search term.
<com.sap.maf.uicontrols.view.MAFSearchBox android:layout_width="wrap_content" android:layout_height="40dp" android:hint="@string/hint_search_box" />
<Style TargetType="TextBox" Key="DefTextBox" platform="android"> <VisualStates> <VisualState Name="Unfocused_Enabled"> <Setter Property="Background" Value="#ff999999" /> <!-- base line color --> <Setter Property="Foreground" Value="#ff333333" /> <!-- text color --> <Setter Property="DetailsForeground" Value="#ff333333" /> <!-- hint color --> <Setter Property="FontFamily" Value="sans_serif" /> <!-- font type --> <Setter Property="FontSize" Value="14" /> <!-- font size --> </VisualState>
<Style TargetType="TextBox" Key="DefTextBox" platform="android"> <VisualStates> <VisualState Name="Unfocused_Enabled"> <Setter Property="Background" Value="#ff999999" /> <!-- base line color --> <Setter Property="Foreground" Value="#ff333333" /> <!-- text color --> <Setter Property="DetailsForeground" Value="#ff333333" /> <!-- hint color --> </VisualState> <VisualState Name="Unfocused_Disabled"> … </VisualState> <VisualState Name="Focused_Disabled"> … </VisualState> <VisualState Name="Focused_Enabled"> … </VisualState> <VisualState Name="Pressed"> … </VisualState> </VisualStates> </Style>
<Style TargetType="TextBox" Key="RedTextBox" BasedOn="DefTextBox" platform="android"> <VisualStates> <VisualState Name="Unfocused_Enabled"> <Setter Property="Background" Value="#0091E0" /> <!-- base line color --> <Setter Property="Foreground" Value="#ff0000" /> <!-- text color --> <Setter Property="DetailsForeground" Value="#F50742" /> <!-- hint color --> </VisualState> </VisualStates> <Setter Property="FontFamily" Value="sans_serif" /> <!-- font type --> <Setter Property="FontSize" Value="14" /> <!-- font size --> </Style>
<com.sap.maf.uicontrols.view.MAFSearchBox android:layout_width="wrap_content" android:layout_height="40dp" x:flavor="RedTextBox" android:hint="@string/hint" />
Background | Base line color |
Foreground | Text color |
FontFamily | Control's font type |
DetailsForeground | Hint color |
FontSize | Font size |