Search in sources :

Example 6 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project danci by ling0322.

the class ReciteFragment method onBackKey.

@Override
public boolean onBackKey() {
    if (recite.isFinsihed() == true) {
        System.exit(0);
    }
    Dialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AnneDialog)).setMessage("单词还没有背完, 确定要退出吗?").setPositiveButton("退出", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface arg0, int arg1) {
            System.exit(0);
        }
    }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface arg0, int arg1) {
        }
    }).create();
    dialog.show();
    return true;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.view.View.OnClickListener)

Example 7 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project XobotOS by xamarin.

the class ActionBarImpl method getThemedContext.

public Context getThemedContext() {
    if (mThemedContext == null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = mContext.getTheme();
        currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
            mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
        } else {
            mThemedContext = mContext;
        }
    }
    return mThemedContext;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 8 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class WindowDecorActionBar method getThemedContext.

public Context getThemedContext() {
    if (mThemedContext == null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = mContext.getTheme();
        currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
            mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
        } else {
            mThemedContext = mContext;
        }
    }
    return mThemedContext;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 9 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class FloatingToolbar method applyDefaultTheme.

/**
     * Returns a re-themed context with controlled look and feel for views.
     */
private static Context applyDefaultTheme(Context originalContext) {
    TypedArray a = originalContext.obtainStyledAttributes(new int[] { R.attr.isLightTheme });
    boolean isLightTheme = a.getBoolean(0, true);
    int themeId = isLightTheme ? R.style.Theme_Material_Light : R.style.Theme_Material;
    a.recycle();
    return new ContextThemeWrapper(originalContext, themeId);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray) Point(android.graphics.Point)

Example 10 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class ListMenuPresenter method initForMenu.

@Override
public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
    if (mThemeRes != 0) {
        mContext = new ContextThemeWrapper(context, mThemeRes);
        mInflater = LayoutInflater.from(mContext);
    } else if (mContext != null) {
        mContext = context;
        if (mInflater == null) {
            mInflater = LayoutInflater.from(mContext);
        }
    }
    mMenu = menu;
    if (mAdapter != null) {
        mAdapter.notifyDataSetChanged();
    }
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper)

Aggregations

ContextThemeWrapper (android.view.ContextThemeWrapper)121 Context (android.content.Context)64 TypedValue (android.util.TypedValue)52 Resources (android.content.res.Resources)32 View (android.view.View)22 TypedArray (android.content.res.TypedArray)16 TextView (android.widget.TextView)16 AlertDialog (android.app.AlertDialog)15 DialogInterface (android.content.DialogInterface)13 OnClickListener (android.content.DialogInterface.OnClickListener)11 Drawable (android.graphics.drawable.Drawable)11 LayoutInflater (android.view.LayoutInflater)10 RecyclerView (android.support.v7.widget.RecyclerView)8 ImageView (android.widget.ImageView)8 MenuBuilder (com.actionbarsherlock.internal.view.menu.MenuBuilder)7 Point (android.graphics.Point)6 ViewStub (android.view.ViewStub)6 WindowManagerImpl (android.view.WindowManagerImpl)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5