Class CheckedTypedItemAdapter<T>

  • All Implemented Interfaces:
    android.widget.Adapter, android.widget.Filterable, android.widget.ListAdapter, android.widget.SpinnerAdapter, android.widget.ThemedSpinnerAdapter, androidx.appcompat.widget.ThemedSpinnerAdapter

    public class CheckedTypedItemAdapter<T>
    extends android.widget.ArrayAdapter<T>
    implements androidx.appcompat.widget.ThemedSpinnerAdapter
    An adapter that's responsible for transforming its items to text representation that's used
    • in a ListView or a Spinner,
    • in Spinner popup menu.
    Additionally checked items will be highlighted.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface androidx.appcompat.widget.ThemedSpinnerAdapter

        androidx.appcompat.widget.ThemedSpinnerAdapter.Helper
    • Field Summary

      • Fields inherited from interface android.widget.Adapter

        IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
    • Constructor Summary

      Constructors 
      Constructor Description
      CheckedTypedItemAdapter​(android.content.Context context, int resource, int textViewResourceId, java.util.List<T> objects)  
      CheckedTypedItemAdapter​(android.content.Context context, int resource, int textViewResourceId, T[] objects)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void bindDropDownView​(android.view.View view, T item)  
      void bindView​(android.view.View view, T item)  
      protected android.view.View createViewFromResource​(android.view.LayoutInflater inflater, android.view.View convertView, android.view.ViewGroup parent, int resource)  
      protected android.widget.TextView findTextView​(android.view.View view)  
      android.view.View getDropDownView​(int position, android.view.View convertView, android.view.ViewGroup parent)  
      android.content.res.Resources.Theme getDropDownViewTheme()  
      java.lang.CharSequence getItemDropDownText​(T item)
      The method is responsible for transforming an object from the list into a string representation that's used in a a popup menu of a Spinner or simple menu / simple dialog of a XpAppCompatSpinner.
      long getItemId​(int position)  
      java.lang.CharSequence getItemText​(T item)
      The method is responsible for transforming an object from the list into a string representation that's used in a ListView or a Spinner.
      android.view.View getView​(int position, android.view.View convertView, android.view.ViewGroup parent)  
      boolean hasStableIds()  
      static <T> CheckedTypedItemAdapter newInstance​(android.content.Context context, java.util.List<T> objects)  
      static <T> CheckedTypedItemAdapter newInstance​(android.content.Context context, T[] objects)  
      void setDropDownViewResource​(int resource)  
      void setDropDownViewTheme​(android.content.res.Resources.Theme theme)  
      • Methods inherited from class android.widget.ArrayAdapter

        add, addAll, addAll, clear, createFromResource, getAutofillOptions, getContext, getCount, getFilter, getItem, getPosition, insert, notifyDataSetChanged, remove, setNotifyOnChange, sort
      • Methods inherited from class android.widget.BaseAdapter

        areAllItemsEnabled, getItemViewType, getViewTypeCount, isEmpty, isEnabled, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface android.widget.Adapter

        getAutofillOptions, getCount, getItem, getItemViewType, getViewTypeCount, isEmpty, registerDataSetObserver, unregisterDataSetObserver
    • Constructor Detail

      • CheckedTypedItemAdapter

        public CheckedTypedItemAdapter​(@NonNull
                                       android.content.Context context,
                                       @LayoutRes
                                       int resource,
                                       @IdRes
                                       int textViewResourceId,
                                       @NonNull
                                       T[] objects)
      • CheckedTypedItemAdapter

        public CheckedTypedItemAdapter​(@NonNull
                                       android.content.Context context,
                                       @LayoutRes
                                       int resource,
                                       @IdRes
                                       int textViewResourceId,
                                       @NonNull
                                       java.util.List<T> objects)
    • Method Detail

      • newInstance

        @NonNull
        public static <T> CheckedTypedItemAdapter newInstance​(@NonNull
                                                              android.content.Context context,
                                                              @NonNull
                                                              T[] objects)
      • newInstance

        @NonNull
        public static <T> CheckedTypedItemAdapter newInstance​(@NonNull
                                                              android.content.Context context,
                                                              @NonNull
                                                              java.util.List<T> objects)
      • hasStableIds

        public boolean hasStableIds()
        Specified by:
        hasStableIds in interface android.widget.Adapter
        Overrides:
        hasStableIds in class android.widget.BaseAdapter
      • getItemId

        public long getItemId​(int position)
        Specified by:
        getItemId in interface android.widget.Adapter
        Overrides:
        getItemId in class android.widget.ArrayAdapter<T>
      • getDropDownView

        @NonNull
        public android.view.View getDropDownView​(int position,
                                                 @Nullable
                                                 android.view.View convertView,
                                                 @NonNull
                                                 android.view.ViewGroup parent)
        Specified by:
        getDropDownView in interface android.widget.SpinnerAdapter
        Overrides:
        getDropDownView in class android.widget.ArrayAdapter<T>
      • getView

        @NonNull
        public android.view.View getView​(int position,
                                         @Nullable
                                         android.view.View convertView,
                                         @NonNull
                                         android.view.ViewGroup parent)
        Specified by:
        getView in interface android.widget.Adapter
        Overrides:
        getView in class android.widget.ArrayAdapter<T>
      • getDropDownViewTheme

        @Nullable
        public android.content.res.Resources.Theme getDropDownViewTheme()
        Specified by:
        getDropDownViewTheme in interface android.widget.ThemedSpinnerAdapter
        Specified by:
        getDropDownViewTheme in interface androidx.appcompat.widget.ThemedSpinnerAdapter
        Overrides:
        getDropDownViewTheme in class android.widget.ArrayAdapter<T>
      • setDropDownViewTheme

        public void setDropDownViewTheme​(@Nullable
                                         android.content.res.Resources.Theme theme)
        Specified by:
        setDropDownViewTheme in interface android.widget.ThemedSpinnerAdapter
        Specified by:
        setDropDownViewTheme in interface androidx.appcompat.widget.ThemedSpinnerAdapter
        Overrides:
        setDropDownViewTheme in class android.widget.ArrayAdapter<T>
      • setDropDownViewResource

        public void setDropDownViewResource​(@LayoutRes
                                            int resource)
        Overrides:
        setDropDownViewResource in class android.widget.ArrayAdapter<T>
      • createViewFromResource

        @NonNull
        protected android.view.View createViewFromResource​(@NonNull
                                                           android.view.LayoutInflater inflater,
                                                           @Nullable
                                                           android.view.View convertView,
                                                           @NonNull
                                                           android.view.ViewGroup parent,
                                                           @LayoutRes
                                                           int resource)
      • findTextView

        @NonNull
        protected android.widget.TextView findTextView​(@NonNull
                                                       android.view.View view)
      • bindDropDownView

        public void bindDropDownView​(@NonNull
                                     android.view.View view,
                                     @NonNull
                                     T item)
      • bindView

        public void bindView​(@NonNull
                             android.view.View view,
                             @NonNull
                             T item)
      • getItemText

        @NonNull
        public java.lang.CharSequence getItemText​(@NonNull
                                                  T item)
        The method is responsible for transforming an object from the list into a string representation that's used in a ListView or a Spinner.
        Parameters:
        item - A data object
        Returns:
        String representation of item.
      • getItemDropDownText

        @NonNull
        public java.lang.CharSequence getItemDropDownText​(@NonNull
                                                          T item)
        The method is responsible for transforming an object from the list into a string representation that's used in a a popup menu of a Spinner or simple menu / simple dialog of a XpAppCompatSpinner.
        Parameters:
        item - A data object
        Returns:
        String representation of item.