Search in sources :

Example 66 with Theme

use of android.content.res.Resources.Theme in project k-9 by k9mail.

the class FoldableLinearLayout method processAttributes.

/**
 * Load given attributes to inner variables,
 *
 * @param context
 * @param attrs
 */
private void processAttributes(Context context, AttributeSet attrs) {
    Theme theme = context.getTheme();
    TypedValue outValue = new TypedValue();
    boolean found = theme.resolveAttribute(R.attr.iconActionCollapse, outValue, true);
    if (found) {
        mIconActionCollapseId = outValue.resourceId;
    }
    found = theme.resolveAttribute(R.attr.iconActionExpand, outValue, true);
    if (found) {
        mIconActionExpandId = outValue.resourceId;
    }
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FoldableLinearLayout, 0, 0);
        mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
        mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
        a.recycle();
    }
    // If any attribute isn't found then set a default one
    mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel;
    mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel;
}
Also used : TypedArray(android.content.res.TypedArray) Theme(android.content.res.Resources.Theme) TypedValue(android.util.TypedValue)

Example 67 with Theme

use of android.content.res.Resources.Theme in project little-bear-dictionary by daimajia.

the class QueryWordFragment method onCreateOptionsMenu.

@SuppressLint("NewApi")
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    mSearchView = new SearchView(mActionBar.getThemedContext());
    mSearchView.setQueryHint(getActivity().getString(R.string.query_hint));
    Theme theme = getActivity().getTheme();
    AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) mSearchView.findViewById(R.id.abs__search_src_text);
    TypedValue typedValue = new TypedValue();
    if (theme.resolveAttribute(R.attr.search_view_text_color, typedValue, true)) {
        autoCompleteTextView.setTextColor(typedValue.data);
    } else {
        autoCompleteTextView.setTextColor(Color.BLACK);
    }
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    layoutParams.setMargins(0, 0, 15, 0);
    mActionBar.setCustomView(mSearchView, layoutParams);
    inflater.inflate(R.menu.search_split_menu, menu);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setId(android.R.id.inputArea);
    mSearchView.setIconifiedByDefault(true);
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) Theme(android.content.res.Resources.Theme) ActionBar(com.actionbarsherlock.app.ActionBar) AutoCompleteTextView(android.widget.AutoCompleteTextView) TypedValue(android.util.TypedValue) SuppressLint(android.annotation.SuppressLint)

Aggregations

Theme (android.content.res.Resources.Theme)67 Resources (android.content.res.Resources)28 Test (org.junit.Test)27 Context (android.content.Context)17 TypedValue (android.util.TypedValue)15 Configuration (android.content.res.Configuration)9 AuthenticatorDescription (android.accounts.AuthenticatorDescription)8 PackageManager (android.content.pm.PackageManager)8 LocalClassLoaderContextThemeWrapper (com.android.settings.utils.LocalClassLoaderContextThemeWrapper)8 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)7 Method (java.lang.reflect.Method)7 PreferenceScreen (android.support.v7.preference.PreferenceScreen)6 ComponentCallbacks2 (android.content.ComponentCallbacks2)5 NotFoundException (android.content.res.Resources.NotFoundException)5 XmlResourceParser (android.content.res.XmlResourceParser)5 INotificationManager (android.app.INotificationManager)4 TypedArray (android.content.res.TypedArray)4 RemoteException (android.os.RemoteException)4 IMountService (android.os.storage.IMountService)4 DisplayMetrics (android.util.DisplayMetrics)4