belongs to Maven artifact androidx.car:car:1.0.0-alpha1

CarListDialog.Builder

public static final class CarListDialog.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.CarListDialog.Builder


Builder class that can be used to create a CarListDialog by configuring the options for the list and behavior of the dialog.

Summary

Public constructors

CarListDialog.Builder(Context context)

Creates a new instance of the Builder.

Public methods

CarListDialog create()

Creates an CarListDialog with the arguments supplied to this Builder.

CarListDialog.Builder setCancelable(boolean cancelable)

Sets whether the dialog is cancelable or not.

CarListDialog.Builder setInitialPosition(int initialPosition)

Sets the initial position in the list that the CarListDialog will start at.

CarListDialog.Builder setItems(String[] items, DialogInterface.OnClickListener onClickListener)

Sets the items that should appear in the list.

CarListDialog.Builder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener)

Sets the callback that will be called if the dialog is canceled.

CarListDialog.Builder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener)

Sets the callback that will be called when the dialog is dismissed for any reason.

CarListDialog.Builder setTitle(CharSequence title)

Sets the title of the dialog for be the given string.

CarListDialog.Builder setTitle(int titleId)

Sets the title of the dialog to be the given string resource.

Inherited methods

Public constructors

CarListDialog.Builder

CarListDialog.Builder (Context context)

Creates a new instance of the Builder.

Parameters
context Context: The Context that the dialog is to be created in.

Public methods

create

CarListDialog create ()

Creates an CarListDialog with the arguments supplied to this Builder.

If setItems(String[], DialogInterface.OnClickListener) is never called, then calling this method will throw an exception.

Calling this method does not display the dialog. Utilize this dialog within a DialogFragment to show the dialog.

Returns
CarListDialog

setCancelable

CarListDialog.Builder setCancelable (boolean cancelable)

Sets whether the dialog is cancelable or not. Default is true.

Parameters
cancelable boolean

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setInitialPosition

CarListDialog.Builder setInitialPosition (int initialPosition)

Sets the initial position in the list that the CarListDialog will start at. When the dialog is created, the list will animate to the given position.

Parameters
initialPosition int: The initial position in the list to display.

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setItems

CarListDialog.Builder setItems (String[] items, 
                DialogInterface.OnClickListener onClickListener)

Sets the items that should appear in the list. The dialog will automatically dismiss itself when an item in the list is clicked on.

If a DialogInterface.OnClickListener is given, then it will be notified of the click. The dialog will still be dismissed afterwards. The which parameter of the DialogInterface.OnClickListener.onClick(DialogInterface, int) method will be the position of the item. This position maps to the index of the item in the given list.

The provided list of items cannot be null or empty. Passing an empty list to this method will throw can exception.

Parameters
items String: The items that will appear in the list.

onClickListener DialogInterface.OnClickListener: The listener that will be notified of a click.

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setOnCancelListener

CarListDialog.Builder setOnCancelListener (DialogInterface.OnCancelListener onCancelListener)

Sets the callback that will be called if the dialog is canceled.

Even in a cancelable dialog, the dialog may be dismissed for reasons other than being canceled or one of the supplied choices being selected. If you are interested in listening for all cases where the dialog is dismissed and not just when it is canceled, see setOnDismissListener(OnDismissListener).

Parameters
onCancelListener DialogInterface.OnCancelListener: The listener to be invoked when this dialog is canceled.

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setOnDismissListener

CarListDialog.Builder setOnDismissListener (DialogInterface.OnDismissListener onDismissListener)

Sets the callback that will be called when the dialog is dismissed for any reason.

Parameters
onDismissListener DialogInterface.OnDismissListener

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setTitle

CarListDialog.Builder setTitle (CharSequence title)

Sets the title of the dialog for be the given string.

Parameters
title CharSequence: The string to be used as the title.

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.

setTitle

CarListDialog.Builder setTitle (int titleId)

Sets the title of the dialog to be the given string resource.

Parameters
titleId int: The resource id of the string to be used as the title.

Returns
CarListDialog.Builder This Builder object to allow for chaining of calls.