Prepares a correctly colored ArrayAdapter for a given theme - Android Graphics

Android examples for Graphics:Color

Description

Prepares a correctly colored ArrayAdapter for a given theme

Demo Code


//package com.java2s;
import android.app.ActionBar;
import android.app.Activity;
import android.widget.ArrayAdapter;

public class Main {
    /**/*  w  ww  .j a v  a  2 s  . c om*/
     * Prepares a correctly colored ArrayAdapter for a given theme
     *
     * @param activity
     * @param items
     */
    public static ArrayAdapter<String> provideNavigationAdapter(
            Activity activity, String[] items) {

        ActionBar actionBar = activity.getActionBar();

        if (actionBar != null) {

            return new ArrayAdapter<String>(
                    actionBar.getThemedContext() != null ? actionBar.getThemedContext()
                            : activity,
                    android.R.layout.simple_list_item_1, items);

        }

        return null;
    }
}

Related Tutorials