SelectionBuilder
@RequiresApi(value = 19)
public class SelectionBuilder
Builder to construct a selection which can be added to a ListBuilder. A selection presents a list of options to the user and allows the user to select exactly one option.
Summary
Public constructors |
|---|
|
Creates a SelectionBuilder with no options. |
Public methods |
|
|---|---|
SelectionBuilder |
addOption(String optionKey, CharSequence optionText)Adds an option to this SelectionBuilder. |
SelectionBuilder |
setContentDescription(@Nullable CharSequence contentDescription)Sets the content description. |
SelectionBuilder |
setInputAction(@NonNull PendingIntent inputAction)Sets the |
SelectionBuilder |
setInputAction(@NonNull RemoteCallback inputAction)Sets the |
SelectionBuilder |
setLayoutDirection(int layoutDirection)Sets the layout direction. |
SelectionBuilder |
setPrimaryAction(@NonNull SliceAction primaryAction)Sets the primary action for the selection slice. |
SelectionBuilder |
setSelectedOption(String selectedOption)Sets which option is selected by default. |
SelectionBuilder |
setSubtitle(@Nullable CharSequence subtitle)Sets the subtitle. |
SelectionBuilder |
setTitle(@Nullable CharSequence title)Sets the title. |
Public constructors
SelectionBuilder
public SelectionBuilder()
Creates a SelectionBuilder with no options.
Public methods
addOption
public SelectionBuilder addOption(String optionKey, CharSequence optionText)
Adds an option to this SelectionBuilder. The new option will be appended to the list of options.
| Parameters | |
|---|---|
String optionKey |
the key that will be returned if the user selects this option |
CharSequence optionText |
the text that will be displayed to the user for this option |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setContentDescription
public SelectionBuilder setContentDescription(@Nullable CharSequence contentDescription)
Sets the content description.
| Parameters | |
|---|---|
@Nullable CharSequence contentDescription |
the content description |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setInputAction
public SelectionBuilder setInputAction(@NonNull PendingIntent inputAction)
Sets the PendingIntent to send when the selection is made or changed. The intent will include an extra with the key EXTRA_SELECTION and a String value containing the key of the key of the selected option.
| Parameters | |
|---|---|
@NonNull PendingIntent inputAction |
the intent to send when the user makes or changes the selection |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setInputAction
public SelectionBuilder setInputAction(@NonNull RemoteCallback inputAction)
Sets the RemoteCallback to send when the selection is made or changed. The intent will include an extra with the key EXTRA_SELECTION and a String value containing the key of the key of the selected option.
| Parameters | |
|---|---|
@NonNull RemoteCallback inputAction |
the intent to send when the user makes or changes the selection |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setLayoutDirection
public SelectionBuilder setLayoutDirection(int layoutDirection)
Sets the layout direction.
| Parameters | |
|---|---|
int layoutDirection |
the layout direction |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setPrimaryAction
public SelectionBuilder setPrimaryAction(@NonNull SliceAction primaryAction)
Sets the primary action for the selection slice. The action specified here will be sent when the whole slice is clicked, or when the app presenting the slice is not capable of rendering a selection interface.
| Parameters | |
|---|---|
@NonNull SliceAction primaryAction |
the action to trigger when the user clicks the whole slice |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setSelectedOption
public SelectionBuilder setSelectedOption(String selectedOption)
Sets which option is selected by default.
| Parameters | |
|---|---|
String selectedOption |
the key of the selected option |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setSubtitle
public SelectionBuilder setSubtitle(@Nullable CharSequence subtitle)
Sets the subtitle.
| Parameters | |
|---|---|
@Nullable CharSequence subtitle |
the subtitle |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |
setTitle
public SelectionBuilder setTitle(@Nullable CharSequence title)
Sets the title.
| Parameters | |
|---|---|
@Nullable CharSequence title |
the title |
| Returns | |
|---|---|
SelectionBuilder |
this SelectionBuilder |