ss按时发翁二无热若无
来源:互联网 发布:1980西安坐标系数据 编辑:程序博客网 时间:2024/05/22 03:24
的是第三方
package android.view;import android.annotation.StyleRes;import android.content.Context;import android.content.ContextWrapper;import android.content.res.Configuration;import android.content.res.Resources;/** * A ContextWrapper that allows you to modify the theme from what is in the * wrapped context. */public class ContextThemeWrapper extends ContextWrapper { private int mThemeResource; private Resources.Theme mTheme; private LayoutInflater mInflater; private Configuration mOverrideConfiguration; private Resources mResources; public ContextThemeWrapper() { super(null); } public ContextThemeWrapper(Context base, @StyleRes int themeResId) { super(base); mThemeResource = themeResId; } public ContextThemeWrapper(Context base, Resources.Theme theme) { super(base); mTheme = theme; } @Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(newBase); } /** * Call to set an "override configuration" on this context -- this is * a configuration that replies one or more values of the standard * configuration that is applied to the context. See * {@link Context#createConfigurationContext(Configuration)} for more * information. * * <p>This method can only be called once, and must be called before any * calls to {@link #getResources()} are made. */ public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException("getResources() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); } @Override public Resources getResources() { if (mResources != null) { return mResources; } if (mOverrideConfiguration == null) { mResources = super.getResources(); return mResources; } else { Context resc = createConfigurationContext(mOverrideConfiguration); mResources = resc.getResources(); return mResources; } } @Override public void setTheme(int resid) { if (mThemeResource != resid) { mThemeResource = resid; initializeTheme(); } } /** @hide */ @Override public int getThemeResId() { return mThemeResource; } @Override public Resources.Theme getTheme() { if (mTheme != null) { return mTheme; } mThemeResource = Resources.selectDefaultTheme(mThemeResource, getApplicationInfo().targetSdkVersion); initializeTheme(); return mTheme; } @Override public Object getSystemService(String name) { if (LAYOUT_INFLATER_SERVICE.equals(name)) { if (mInflater == null) { mInflater = LayoutInflater.from(getBaseContext()).cloneInContext(this); } return mInflater; } return getBaseContext().getSystemService(name); } /** * Called by {@link #setTheme} and {@link #getTheme} to apply a theme * resource to the current Theme object. Can override to change the * default (simple) behavior. This method will not be called in multiple * threads simultaneously. * * @param theme The Theme object being modified. * @param resid The theme style resource being applied to <var>theme</var>. * @param first Set to true if this is the first time a style is being * applied to <var>theme</var>. */ protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { theme.applyStyle(resid, true); } private void initializeTheme() { final boolean first = mTheme == null; if (first) { mTheme = getResources().newTheme(); Resources.Theme theme = getBaseContext().getTheme(); if (theme != null) { mTheme.setTo(theme); } } onApplyThemeResource(mTheme, mThemeResource, first); }}
0 0
- ss按时发翁二无热若无
- 按时
- 按时
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- ss
- Android进阶——多线程系列之四大线程池的使用介绍
- 4.Draftjs 学习笔记-Decorators
- [GI系列]0.0-下一阶段博文说明
- Mybatis中使用Association元素进行一对一级联查询
- Unity 游戏框架搭建 (五) 简易消息机制
- ss按时发翁二无热若无
- SRAM和SDRAM的区别
- List数组排序
- 国内成品油价格将迎“两连涨” 或刷新年内最高涨幅
- Unity 游戏框架搭建 (六) 关于框架的一些好文和一些思考
- iOS UILabel的高度随着字数的多少变化而变化
- iOS 升级HTTPS配置ATS-----(2)------
- 光盘刻录之 IFileSystemNone
- apache+mod_python的安装与配置