當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.newTheme方法代碼示例

本文整理匯總了Java中android.content.res.Resources.newTheme方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.newTheme方法的具體用法?Java Resources.newTheme怎麽用?Java Resources.newTheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.newTheme方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadResources

import android.content.res.Resources; //導入方法依賴的package包/類
protected void loadResources() {
    try {
        AssetManager assetManager = AssetManager.class.newInstance();
        Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
        addAssetPath.invoke(assetManager, dexpath);
        mAssetManager = assetManager;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Resources superRes = super.getResources();
    superRes.getDisplayMetrics();
    superRes.getConfiguration();
    mResources = new Resources(mAssetManager, superRes.getDisplayMetrics(),superRes.getConfiguration());
    mTheme = mResources.newTheme();
    mTheme.setTo(super.getTheme());
}
 
開發者ID:zyj1609wz,項目名稱:Dynamic,代碼行數:17,代碼來源:MainActivity.java

示例2: hookActivityResources

import android.content.res.Resources; //導入方法依賴的package包/類
public static void hookActivityResources(Activity activity, String packageName) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isVivo(activity.getResources())) {
        // for 5.0+ vivo
        return;
    }

    // designed for 5.0 - only, but some bad phones not work, eg:letv
    try {
        Context base = activity.getBaseContext();
        final LoadedPlugin plugin = PluginManager.getInstance(activity).getLoadedPlugin(packageName);
        final Resources resources = plugin.getResources();
        if (resources != null) {
            ReflectUtil.setField(base.getClass(), base, "mResources", resources);

            // copy theme
            Resources.Theme theme = resources.newTheme();
            theme.setTo(activity.getTheme());
            int themeResource = (int)ReflectUtil.getField(ContextThemeWrapper.class, activity, "mThemeResource");
            theme.applyStyle(themeResource, true);
            ReflectUtil.setField(ContextThemeWrapper.class, activity, "mTheme", theme);

            ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", resources);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:28,代碼來源:PluginUtil.java

示例3: loadResources

import android.content.res.Resources; //導入方法依賴的package包/類
protected void loadResources() throws InstantiationException, IllegalAccessException, IllegalArgumentException,
        InvocationTargetException, NoSuchMethodException, NoSuchFieldException {
    Log.d(TAG, "MyApplication : loadResources()");
    AssetManager am = (AssetManager) AssetManager.class.newInstance();
    am.getClass().getMethod("addAssetPath", String.class).invoke(am, dexPath);
    mAssetManager = am;
    Constructor<?> constructor_Resources = Resources.class.getConstructor(AssetManager.class, cc.getResources()
            .getDisplayMetrics().getClass(), cc.getResources().getConfiguration().getClass());
    mResources = (Resources) constructor_Resources.newInstance(am, cc.getResources().getDisplayMetrics(), cc.getResources().getConfiguration());
    mTheme = mResources.newTheme();
    mTheme.applyStyle(android.R.style.Theme_Light_NoTitleBar_Fullscreen, true);
}
 
開發者ID:Catherine22,項目名稱:ClassLoader,代碼行數:13,代碼來源:MyApplication.java


注:本文中的android.content.res.Resources.newTheme方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。