public class BottomSheet extends android.app.Dialog implements android.content.DialogInterface, DraggableView.Callback
BottomSheet.Builder.create() or BottomSheet.Builder.show() of the builder BottomSheet.Builder can be
used.| Modifier and Type | Class and Description |
|---|---|
static class |
BottomSheet.Builder
A builder, which allows to create and show bottom sheets, which are designed according to
Android 5's Material Design guidelines even on pre-Lollipop devices.
|
static class |
BottomSheet.Style
Contains all possible styles of a
BottomSheet. |
android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnClickListener, android.content.DialogInterface.OnDismissListener, android.content.DialogInterface.OnKeyListener, android.content.DialogInterface.OnMultiChoiceClickListener, android.content.DialogInterface.OnShowListener| Modifier | Constructor and Description |
|---|---|
protected |
BottomSheet(android.content.Context context,
int themeResourceId)
Creates a bottom sheet, which is designed according to Android 5's Material Design guidelines
even on pre-Lollipop devices.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDivider()
Adds a new divider to the bottom sheet.
|
void |
addDivider(java.lang.CharSequence title)
Adds a new divider to the bottom sheet.
|
void |
addDivider(int titleId)
Adds a new divider to the bottom sheet.
|
void |
addItem(int id,
java.lang.CharSequence title)
Adds a new item to the bottom sheet.
|
void |
addItem(int id,
java.lang.CharSequence title,
android.graphics.drawable.Drawable icon)
Adds a new item to the bottom sheet.
|
void |
addItem(int id,
int titleId)
Adds a new item to the bottom sheet.
|
void |
addItem(int id,
int titleId,
int iconId)
Adds a new item to the bottom sheet.
|
void |
cancel() |
void |
dismiss() |
android.graphics.drawable.Drawable |
getBackground()
Returns the background of the bottom sheet.
|
float |
getDimAmount()
Returns the dim amount, which is used to darken the area outside the bottom sheet.
|
int |
getDividerColor()
Returns the color of the dividers of the bottom sheet.
|
float |
getDragSensitivity()
Returns the sensitivity, which specifies the distance after which dragging has an effect on
the bottom sheet, in relation to an internal value range.
|
android.widget.GridView |
getGridView()
Returns the grid view, which is contained by the bottom sheet.
|
android.graphics.drawable.Drawable |
getIcon()
Returns the icon of the bottom sheet.
|
int |
getId(int index)
Returns the id of the item, which corresponds to a specific index.
|
int |
getItemColor()
Returns the color of the items of the bottom sheet.
|
int |
getItemCount()
Returns the number of items, which are currently contained by the bottom sheet.
|
android.widget.ListAdapter |
getListAdapter()
Returns the adapter of the grid view, which is contained by the bottom sheet.
|
BottomSheet.Style |
getStyle()
Returns the style, which is used to display the bottom sheet's items.
|
java.lang.CharSequence |
getTitle()
Returns the title of the bottom sheet.
|
int |
getTitleColor()
Returns the color of the title of the bottom sheet.
|
int |
getWidth()
Returns the width of the bottom sheet.
|
int |
indexOf(int id)
Returns the index of the item, which corresponds to a specific id.
|
void |
invalidate()
Invalidates the bottom sheet.
|
void |
invalidateOnChange(boolean invalidateOnChange)
Sets, whether the bottom sheet should automatically be invalidated, when its items have been
changed, or not.
|
boolean |
isEmpty()
Returns, whether the bottom sheet contains any items, or not.
|
boolean |
isItemEnabled(int index)
Returns, whether the item at a specific index is enabled, or not.
|
boolean |
isMaximized()
Returns, whether the bottom sheet is currently maximized, or not.
|
void |
maximize()
Maximizes the bottom sheet.
|
void |
onHidden(boolean canceled)
The method, which is invoked, when the view has been hidden.
|
void |
onMaximized()
The method, which is invoked, when the view has been maximized.
|
void |
onRestoreInstanceState(android.os.Bundle savedInstanceState) |
android.os.Bundle |
onSaveInstanceState() |
void |
onStart() |
void |
onStop() |
void |
removeAllItems()
Removes all items from the bottom sheet.
|
void |
removeItem(int index)
Removes the item with at a specific index from the bottom sheet.
|
void |
setBackground(android.graphics.Bitmap background)
Sets the background of the bottom sheet.
|
void |
setBackground(int resourceId)
Sets the background of the bottom sheet.
|
void |
setBackgroundColor(int color)
Sets the background color of the bottom sheet.
|
void |
setCancelable(boolean cancelable) |
void |
setCanceledOnTouchOutside(boolean canceledOnTouchOutside) |
void |
setCustomTitle(int resourceId)
Sets the custom view, which should be used to show the title of the bottom sheet.
|
void |
setCustomTitle(android.view.View view)
Sets the custom view, which should be used to show the title of the bottom sheet.
|
void |
setDimAmount(float dimAmount)
Sets the dim amount, which should be used to darken the area outside the bottom sheet.
|
void |
setDivider(int index)
Replaces the item at a specific index with a divider.
|
void |
setDivider(int index,
java.lang.CharSequence title)
Replaces the item at a specific index with a divider.
|
void |
setDivider(int index,
int titleId)
Replaces the item at a specific index with a divider.
|
void |
setDividerColor(int color)
Sets the color of the dividers of the bottom sheet.
|
void |
setDragSensitivity(float dragSensitivity)
Sets the sensitivity, which specifies the distance after which dragging has an effect on the
bottom sheet, in relation to an internal value range.
|
void |
setIcon(android.graphics.Bitmap icon)
Sets the icon of the bottom sheet.
|
void |
setIcon(int resourceId)
Sets the icon of the bottom sheet.
|
void |
setIconAttribute(int attributeId)
Set the icon of the bottom sheet.
|
void |
setIntent(android.app.Activity activity,
android.content.Intent intent)
Adds the apps, which are able to handle a specific intent, as items to the bottom sheet.
|
void |
setItem(int index,
int id,
java.lang.CharSequence title)
Replaces the item at a specific index with another item.
|
void |
setItem(int index,
int id,
java.lang.CharSequence title,
android.graphics.drawable.Drawable icon)
Replaces the item at a specific index with another item.
|
void |
setItem(int index,
int id,
int titleId)
Replaces the item at a specific index with another item.
|
void |
setItem(int index,
int id,
int titleId,
int iconId)
Replaces the item at a specific index with another item.
|
void |
setItemColor(int color)
Sets the color of the items of the bottom sheet.
|
void |
setItemEnabled(int index,
boolean enabled)
Sets, whether the item at a specific index should be enabled, or not.
|
void |
setOnItemClickListener(android.widget.AdapterView.OnItemClickListener listener)
Sets the listener, which should be notified, when an item of the bottom sheet has been
clicked.
|
void |
setOnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener listener)
Sets the listener, which should be notified, when an item of the bottom sheet has been
long-clicked.
|
void |
setOnMaximizeListener(OnMaximizeListener listener)
Sets the listener, which should be notified, when the bottom sheet has been maximized.
|
void |
setOnShowListener(android.content.DialogInterface.OnShowListener listener) |
void |
setStyle(BottomSheet.Style style)
Sets the style, which should be used to display the bottom sheet's items.
|
void |
setTitle(java.lang.CharSequence title) |
void |
setTitleColor(int color)
Sets the color of the title of the bottom sheet.
|
void |
setView(int resourceId)
Sets the custom view, which should be shown by the bottom sheet.
|
void |
setView(android.view.View view)
Sets the custom view, which should be shown by the bottom sheet.
|
void |
setWidth(int width)
Sets the width of the bottom sheet.
|
addContentView, closeOptionsMenu, create, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, getActionBar, getContext, getCurrentFocus, getLayoutInflater, getOwnerActivity, getSearchEvent, getVolumeControlStream, getWindow, hide, invalidateOptionsMenu, isShowing, onActionModeFinished, onActionModeStarted, onAttachedToWindow, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onSearchRequested, onSearchRequested, onTouchEvent, onTrackballEvent, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, registerForContextMenu, requestWindowFeature, setCancelMessage, setContentView, setContentView, setContentView, setDismissMessage, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setOnCancelListener, setOnDismissListener, setOnKeyListener, setOwnerActivity, setTitle, setVolumeControlStream, show, takeKeyEvents, unregisterForContextMenuprotected BottomSheet(android.content.Context context,
int themeResourceId)
context - The context, which should be used by the bottom sheet, as an instance of the class
Context. The context may not be nullthemeResourceId - The resource id of the theme, which should be used by the bottom sheet, as an Integer value. The resource id must correspond to a valid themepublic final void setOnItemClickListener(android.widget.AdapterView.OnItemClickListener listener)
listener - The listener, which should be set, as an instance of the type AdapterView.OnItemClickListener or null, if no listener should be notifiedpublic final void setOnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener listener)
listener - The listener, which should be set, as an instance of the type AdapterView.OnItemLongClickListener or null, if no listener should be notifiedpublic final void setOnMaximizeListener(OnMaximizeListener listener)
listener - The listener, which should be set, as an instance of the type OnMaximizeListener or null, if no listener should be notifiedpublic final android.widget.GridView getGridView()
GridView or null, if the bottom sheet does not show any items or has not been shown
yetpublic final android.widget.ListAdapter getListAdapter()
ListAdapterpublic final android.graphics.drawable.Drawable getIcon()
Drawable or null,
if no icon has been setpublic final void setIcon(android.graphics.Bitmap icon)
icon - The icon, which should be set, as an instance of the class Bitmap or null, if
no icon should be shownpublic final void setIcon(int resourceId)
resourceId - The resource id of the icon, which should be set, as an Integer value. The
resource id must correspond to a valid drawable resourcepublic final void setIconAttribute(int attributeId)
attributeId - The id of the theme attribute, which supplies the icon, which should be set, as an
Integer value. The id must point to a valid drawable resourcepublic final int getTitleColor()
Integer value or -1, if no
custom color has been setpublic final void setTitleColor(int color)
color - The color, which should be set, as an Integer valuepublic final int getItemColor()
Integer value or -1, if no
custom color has been setpublic final void setItemColor(int color)
color - The color, which should be set, as an Integer value or -1, if no custom color
should be setpublic final int getDividerColor()
Integer value or -1, if
no custom color has been setpublic final void setDividerColor(int color)
color - The color, which should be set, as an Integer value or -1, if no custom color
should be setpublic final android.graphics.drawable.Drawable getBackground()
Drawable or
null, if no custom background has been setpublic final void setBackground(android.graphics.Bitmap background)
background - The background, which should be set, as an instance of the class Bitmap or
null, if no custom background should be setpublic final void setBackground(int resourceId)
resourceId - The resource id of the background, which should be set, as an Integer value.
The resource id must correspond to a valid drawable resourcepublic final void setBackgroundColor(int color)
color - The background color, which should be set, as an Integer value or -1, if no
custom background color should be setpublic final void setCustomTitle(android.view.View view)
view - The view, which should be set, as an instance of the class View or null, if
no custom view should be used to show the titlepublic final void setCustomTitle(int resourceId)
resourceId - The resource id of the view, which should be set, as an Integer value. The
resource id must correspond to a valid layout resourcepublic final void setView(android.view.View view)
view - The view, which should be set, as an instance of the class View or null, if
no custom view should be shownpublic final void setView(int resourceId)
resourceId - The resource id of the view, which should be set, as an Integer value. The
resource id must correspond to a valid layout resourcepublic final float getDragSensitivity()
Float value. The drag sensitivity must be at lest 0
and at maximum 1public final void setDragSensitivity(float dragSensitivity)
dragSensitivity - The drag sensitivity, which should be set, as a Float value. The drag
sensitivity must be at lest 0 and at maximum 1public final float getDimAmount()
Float valuepublic final void setDimAmount(float dimAmount)
dimAmount - The dim amount, which should be set, as a Float value. The dim amount must be
at least 0 (fully transparent) and at maximum 1 (fully opaque)public final int getWidth()
Integer valuepublic final void setWidth(int width)
width - The width, which should be set, in pixels as an Integer value. The width must
be at least 1public final void addItem(int id,
java.lang.CharSequence title)
id - The id of the item, which should be added, as an Integer value. The id must
be at least 0title - The title of the item, which should be added, as an instance of the type CharSequence. The title may neither be null, nor emptypublic final void addItem(int id,
java.lang.CharSequence title,
android.graphics.drawable.Drawable icon)
id - The id of the item, which should be added, as an Integer value. The id must
be at least 0title - The title of the item, which should be added, as an instance of the type CharSequence. The title may neither be null, nor emptyicon - The icon of the item, which should be added, as an instance of the class Drawable, or null, if no item should be usedpublic final void addItem(int id,
int titleId)
id - The id of the item, which should be added, as an Integer value. The id must
be at least 0titleId - The resource id of the title of the item, which should be added, as an Integer value. The resource id must correspond to a valid string resourcepublic final void addItem(int id,
int titleId,
int iconId)
id - The id of the item, which should be added, as an Integer value. The id must
be at least 0titleId - The resource id of the title of the item, which should be added, as an Integer value. The resource id must correspond to a valid string resourceiconId - The resource id of the icon of the item, which should be added, as an Integer
value. The resource id must correspond to a valid drawable resourcepublic final void setItem(int index,
int id,
java.lang.CharSequence title)
index - The index of the item, which should be replaced, as an Integer valueid - The id of the item, which should be added, as an Integer value. The id must
be at least 0title - The title of the item, which should be added, as an instance of the type CharSequence. The title may neither be null, nor emptypublic final void setItem(int index,
int id,
java.lang.CharSequence title,
android.graphics.drawable.Drawable icon)
index - The index of the item, which should be replaced, as an Integer valueid - The id of the item, which should be added, as an Integer value. The id must
be at least 0title - The title of the item, which should be added, as an instance of the type CharSequence. The title may neither be null, nor emptyicon - The icon of the item, which should be added, as an instance of the class Drawable, or null, if no item should be usedpublic final void setItem(int index,
int id,
int titleId)
index - The index of the item, which should be replaced, as an Integer valueid - The id of the item, which should be added, as an Integer value. The id must
be at least 0titleId - The resource id of the title of the item, which should be added, as an Integer value. The resource id must correspond to a valid string resourcepublic final void setItem(int index,
int id,
int titleId,
int iconId)
index - The index of the item, which should be replaced, as an Integer valueid - The id of the item, which should be added, as an Integer value. The id must
be at least 0titleId - The resource id of the title of the item, which should be added, as an Integer value. The resource id must correspond to a valid string resourceiconId - The resource id of the icon of the item, which should be added, as an Integer
value. The resource id must correspond to a valid drawable resourcepublic final void addDivider()
public final void addDivider(java.lang.CharSequence title)
title - The title of the divider, which should be added, as an instance of the type CharSequence, or null, if no title should be usedpublic final void addDivider(int titleId)
titleId - The resource id of the title of the divider, which should be added, as an Integer value. The resource id must correspond to a valid string resourcepublic final void setDivider(int index)
index - The index of the item, which should be replaced, as an Integer valuepublic final void setDivider(int index,
java.lang.CharSequence title)
index - The index of the item, which should be replaced, as an Integer valuetitle - The title of the divider, which should be added, as an instance of the type CharSequence, or null, if no title should be usedpublic final void setDivider(int index,
int titleId)
index - The index of the item, which should be replaced, as an Integer valuetitleId - The resource id of the title of the divider, which should be added, as an Integer value. The resource id must correspond to a valid string resourcepublic final void removeItem(int index)
index - The index of the item, which should be removed, as an Integer valuepublic final void removeAllItems()
public final boolean isEmpty()
public final int getItemCount()
Integer value or -1, if the bottom sheet does not show any items or has not been shown yetpublic final int indexOf(int id)
id - The id of the item, whose index should be returned, as an Integer value. The
id must be at least 0public final int getId(int index)
index - The index of the item, whose id should be returned, as an Integer valueDivider#DIVIDER_ID, if the item is a dividerpublic final boolean isItemEnabled(int index)
index - The index of the item, which should be checked, as an Integer valuepublic final void setItemEnabled(int index,
boolean enabled)
index - The index of the item as an Integer valueenabled - True, if the item should be enabled, false otherwisepublic final void setIntent(android.app.Activity activity,
android.content.Intent intent)
activity - The activity, the bottom sheet belongs to, as an instance of the class Activity. The activity may not be nullintent - The intent as an instance of the class Intent. The intent may not be nullpublic final void invalidate()
public final void invalidateOnChange(boolean invalidateOnChange)
invalidateOnChange - True, if the bottom sheet should automatically be invalidated, when its items have
been changed, false otherwisepublic final boolean isMaximized()
public final void maximize()
public final BottomSheet.Style getStyle()
BottomSheet.Stylepublic final void setStyle(BottomSheet.Style style)
style - The style, which should be set, as a value of the enum BottomSheet.Style. The style may
either be LIST, LIST_COLUMNS or GRIDpublic final java.lang.CharSequence getTitle()
CharSequence or
null, if no title has been setpublic final void setTitle(java.lang.CharSequence title)
setTitle in class android.app.Dialogpublic final void dismiss()
dismiss in interface android.content.DialogInterfacedismiss in class android.app.Dialogpublic final void cancel()
cancel in interface android.content.DialogInterfacecancel in class android.app.Dialogpublic final void setCancelable(boolean cancelable)
setCancelable in class android.app.Dialogpublic final void setCanceledOnTouchOutside(boolean canceledOnTouchOutside)
setCanceledOnTouchOutside in class android.app.Dialogpublic final void setOnShowListener(android.content.DialogInterface.OnShowListener listener)
setOnShowListener in class android.app.Dialogpublic final void onMaximized()
DraggableView.CallbackonMaximized in interface DraggableView.Callbackpublic final void onHidden(boolean canceled)
DraggableView.CallbackonHidden in interface DraggableView.Callbackcanceled - True, if the view has been canceled, false otherwisepublic final void onStart()
onStart in class android.app.Dialogpublic final void onStop()
onStop in class android.app.Dialogpublic final android.os.Bundle onSaveInstanceState()
onSaveInstanceState in class android.app.Dialogpublic final void onRestoreInstanceState(android.os.Bundle savedInstanceState)
onRestoreInstanceState in class android.app.Dialog