public final class

ThemedSpinnerAdapter.Helper

extends java.lang.Object

 java.lang.Object

↳androidx.appcompat.widget.ThemedSpinnerAdapter.Helper

Overview

A helper class which allows easy integration of ThemedSpinnerAdapter into existing s in a backwards compatible way.

An example implementation would be:

 public class MyAdapter extends BaseAdapter implements ThemedSpinnerAdapter {
     private final ThemedSpinnerAdapter.Helper mDropDownHelper;

     public CheeseAdapter(Context context) {
         mDropDownHelper = new ThemedSpinnerAdapter.Helper(context);
         // ...
     }

     @Override
     public View getDropDownView(int position, View convertView, ViewGroup parent) {
         View view;

         if (convertView == null) {
             // Inflate the drop down using the helper's LayoutInflater
             LayoutInflater inflater = mDropDownHelper.getDropDownViewInflater();
             view = inflater.inflate(R.layout.my_dropdown, parent, false);
         }

         // ...
     }

     @Override
     public void setDropDownViewTheme(@Nullable Resources.Theme theme) {
         // Pass the new theme to the helper
         mDropDownHelper.setDropDownViewTheme(theme);
     }

     @Override
     public Resources.Theme getDropDownViewTheme() {
         // Return the helper's value
         return mDropDownHelper.getDropDownViewTheme();
     }
 }
 

Summary

Constructors
publicHelper(Context context)

Methods
public LayoutInflatergetDropDownViewInflater()

Returns the LayoutInflater which should be used when inflating any layouts from your .

public Resources.ThemegetDropDownViewTheme()

Should be called from your adapter's ThemedSpinnerAdapter.getDropDownViewTheme(), returning the value returned from this method.

public voidsetDropDownViewTheme(Resources.Theme theme)

Should be called from your adapter's ThemedSpinnerAdapter

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Helper(Context context)

Methods

public void setDropDownViewTheme(Resources.Theme theme)

Should be called from your adapter's ThemedSpinnerAdapter

Parameters:

theme: the theme passed in to ThemedSpinnerAdapter

public Resources.Theme getDropDownViewTheme()

Should be called from your adapter's ThemedSpinnerAdapter.getDropDownViewTheme(), returning the value returned from this method.

public LayoutInflater getDropDownViewInflater()

Returns the LayoutInflater which should be used when inflating any layouts from your .

The instance returned will have a correct theme, meaning that any inflated views will be created with the same theme.