Class DynamicSpinnerChoiceAdapter
java.lang.Object
android.widget.BaseAdapter
com.pranavpandey.android.dynamic.support.adapter.DynamicSpinnerChoiceAdapter
- All Implemented Interfaces:
Adapter
,ListAdapter
,SpinnerAdapter
A simple base adapter to hold an array of char sequence and display them in an adapter view.
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Default value for the selected position.Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
-
Constructor Summary
ConstructorDescriptionDynamicSpinnerChoiceAdapter
(int[] iconsRes, Drawable[] icons, CharSequence[] titles, CharSequence[] subtitles, boolean[] hasSubmenus, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, boolean[] hasSubmenus, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, CharSequence[] subtitles, boolean[] hasSubmenus, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, CharSequence[] subtitles, boolean[] hasSubmenus, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(int[] iconsRes, CharSequence[] titles, CharSequence[] subtitles, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, boolean[] hasSubmenus, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, CharSequence[] subtitles, boolean[] hasSubmenus, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, CharSequence[] subtitles, boolean[] hasSubmenus, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(Drawable[] icons, CharSequence[] titles, CharSequence[] subtitles, int selectedPosition, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.DynamicSpinnerChoiceAdapter
(CharSequence[] titles, AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class. -
Method Summary
Modifier and TypeMethodDescriptionint
getCount()
boolean[]
Get the array of submenu states used by this adapter.Returns the icon for the supplied position.Drawable[]
getIcons()
Get the array of icons used by this adapter.int[]
Get the array of icons used by this adapter.getItem
(int position) long
getItemId
(int position) Get the item click listener.int
Get the selected position.Get the array of subtitles used by this adapter.Get the array of titles used by this adapter.void
setHasSubmenus
(boolean[] entries) Sets the array of submenu states for this adapter.void
Sets the array of icons for this adapter.void
setIconsRes
(int[] iconsRes) Sets the array of icons for this adapter.void
setOnItemClickListener
(AdapterView.OnItemClickListener onItemClickListener) Sets the listener to get the callback when an item is clicked.void
setSelectedPosition
(int selectedPosition) Sets the selected position.void
setSubtitles
(CharSequence[] entries) Sets the array of subtitles for this adapter.void
setTitles
(CharSequence[] titles) Sets the array of titles for this adapter.Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getAutofillOptions, getDropDownView, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
-
Field Details
-
DEFAULT_SELECTED_POSITION
public static int DEFAULT_SELECTED_POSITIONDefault value for the selected position.
-
-
Constructor Details
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable CharSequence[] titles, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
titles
- The titles for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, @Nullable boolean[] hasSubmenus, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.hasSubmenus
- The submenu states for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable boolean[] hasSubmenus, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.hasSubmenus
- The submenu states for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, @Nullable boolean[] hasSubmenus, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.hasSubmenus
- The submenu states for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, @Nullable boolean[] hasSubmenus, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.hasSubmenus
- The submenu states for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, @Nullable boolean[] hasSubmenus, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.hasSubmenus
- The submenu states for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, @Nullable boolean[] hasSubmenus, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
icons
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.hasSubmenus
- The submenu states for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
DynamicSpinnerChoiceAdapter
public DynamicSpinnerChoiceAdapter(@Nullable int[] iconsRes, @Nullable Drawable[] icons, @Nullable CharSequence[] titles, @Nullable CharSequence[] subtitles, @Nullable boolean[] hasSubmenus, int selectedPosition, @Nullable AdapterView.OnItemClickListener onItemClickListener) Constructor to initialize an object of this class.- Parameters:
iconsRes
- The icons for this adapter.icons
- The icons for this adapter.titles
- The titles for this adapter.subtitles
- The subtitles for this adapter.hasSubmenus
- The submenu states for this adapter.selectedPosition
- The selected menu position for this adapter.onItemClickListener
- The listener to get the callback when an item is clicked.
-
-
Method Details
-
getView
-
getCount
public int getCount() -
getItem
-
getItemId
public long getItemId(int position) -
getIconsRes
Get the array of icons used by this adapter.- Returns:
- The array of icons used by this adapter.
-
setIconsRes
Sets the array of icons for this adapter.- Parameters:
iconsRes
- The array of drawable resource ids to be set.
-
getIcons
Get the array of icons used by this adapter.- Returns:
- The array of icons used by this adapter.
-
setIcons
Sets the array of icons for this adapter.- Parameters:
icons
- The array of drawable resource ids to be set.
-
getIcon
Returns the icon for the supplied position.- Parameters:
context
- The context to be used.position
- The position of the icon.- Returns:
- The icon for the supplied position.
-
getTitles
Get the array of titles used by this adapter.- Returns:
- The array of titles used by this adapter.
-
setTitles
Sets the array of titles for this adapter.- Parameters:
titles
- The array of titles to be set.
-
getSubtitles
Get the array of subtitles used by this adapter.- Returns:
- The array of subtitles used by this adapter.
-
setSubtitles
Sets the array of subtitles for this adapter.- Parameters:
entries
- The array of subtitles to be set.
-
getOnItemClickListener
Get the item click listener.- Returns:
- The listener to get the callback when an item is clicked.
-
setOnItemClickListener
Sets the listener to get the callback when an item is clicked.- Parameters:
onItemClickListener
- The listener to be set.
-
getSelectedPosition
public int getSelectedPosition()Get the selected position.- Returns:
- The selected position.
-
setSelectedPosition
public void setSelectedPosition(int selectedPosition) Sets the selected position.- Parameters:
selectedPosition
- The position to be selected.
-