Skip to content

Most visited

Recently visited

navigation
added in version 25.1.0
belongs to Maven artifact com.android.support:appcompat-v7:27.0.0

ThemedSpinnerAdapter.Helper

public static final class ThemedSpinnerAdapter.Helper
extends Object

java.lang.Object
   ↳ android.support.v7.widget.ThemedSpinnerAdapter.Helper


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

An example BaseAdapter 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

Public constructors

ThemedSpinnerAdapter.Helper(Context context)

Public methods

LayoutInflater getDropDownViewInflater()

Returns the LayoutInflater which should be used when inflating any layouts from your getDropDownView(int, View, ViewGroup).

Resources.Theme getDropDownViewTheme()

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

void setDropDownViewTheme(Resources.Theme theme)

Should be called from your adapter's setDropDownViewTheme(Theme)

Inherited methods

From class java.lang.Object

Public constructors

ThemedSpinnerAdapter.Helper

added in version 25.1.0
ThemedSpinnerAdapter.Helper (Context context)

Parameters
context Context

Public methods

getDropDownViewInflater

added in version 25.1.0
LayoutInflater getDropDownViewInflater ()

Returns the LayoutInflater which should be used when inflating any layouts from your getDropDownView(int, View, ViewGroup).

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

Returns
LayoutInflater

getDropDownViewTheme

added in version 25.1.0
Resources.Theme getDropDownViewTheme ()

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

Returns
Resources.Theme

setDropDownViewTheme

added in version 25.1.0
void setDropDownViewTheme (Resources.Theme theme)

Should be called from your adapter's setDropDownViewTheme(Theme)

Parameters
theme Resources.Theme: the theme passed in to setDropDownViewTheme(Theme)

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)