Class DynamicSpinnerChoiceAdapter

java.lang.Object
android.widget.BaseAdapter
com.pranavpandey.android.dynamic.support.adapter.DynamicSpinnerChoiceAdapter
All Implemented Interfaces:
Adapter, ListAdapter, SpinnerAdapter

public class DynamicSpinnerChoiceAdapter extends BaseAdapter
A simple base adapter to hold an array of char sequence and display them in an adapter view.
  • Field Details

    • DEFAULT_SELECTED_POSITION

      public static int DEFAULT_SELECTED_POSITION
      Default 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

      public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    • getCount

      public int getCount()
    • getItem

      public Object getItem(int position)
    • getItemId

      public long getItemId(int position)
    • getIconsRes

      @Nullable public int[] getIconsRes()
      Get the array of icons used by this adapter.
      Returns:
      The array of icons used by this adapter.
    • setIconsRes

      public void setIconsRes(@Nullable int[] iconsRes)
      Sets the array of icons for this adapter.
      Parameters:
      iconsRes - The array of drawable resource ids to be set.
    • getIcons

      @Nullable public Drawable[] getIcons()
      Get the array of icons used by this adapter.
      Returns:
      The array of icons used by this adapter.
    • setIcons

      public void setIcons(@Nullable Drawable[] icons)
      Sets the array of icons for this adapter.
      Parameters:
      icons - The array of drawable resource ids to be set.
    • getIcon

      @Nullable public Drawable getIcon(@Nullable Context context, int position)
      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

      @Nullable public CharSequence[] getTitles()
      Get the array of titles used by this adapter.
      Returns:
      The array of titles used by this adapter.
    • setTitles

      public void setTitles(@Nullable CharSequence[] titles)
      Sets the array of titles for this adapter.
      Parameters:
      titles - The array of titles to be set.
    • getSubtitles

      @Nullable public CharSequence[] getSubtitles()
      Get the array of subtitles used by this adapter.
      Returns:
      The array of subtitles used by this adapter.
    • setSubtitles

      public void setSubtitles(@Nullable CharSequence[] entries)
      Sets the array of subtitles for this adapter.
      Parameters:
      entries - The array of subtitles to be set.
    • getHasSubmenus

      @Nullable public boolean[] getHasSubmenus()
      Get the array of submenu states used by this adapter.
      Returns:
      The array of submenu states used by this adapter.
    • setHasSubmenus

      public void setHasSubmenus(@Nullable boolean[] entries)
      Sets the array of submenu states for this adapter.
      Parameters:
      entries - The array of submenu states to be set.
    • getOnItemClickListener

      @Nullable public AdapterView.OnItemClickListener getOnItemClickListener()
      Get the item click listener.
      Returns:
      The listener to get the callback when an item is clicked.
    • setOnItemClickListener

      public void setOnItemClickListener(@Nullable AdapterView.OnItemClickListener onItemClickListener)
      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.