如何从Android资源类中获取样式?

3
我正在Android应用程序之间切换,我传递一系列参数以定制其他应用程序(颜色、标志等),但我找不到我传递的样式,我只能找到可绘制对象、颜色和布局。
有没有办法找到这些样式?
我正在使用以下内容:
Intent intent = new Intent();
        intent.setClassName("com.app.to.call", "com.app.to.call.LoginActivity");
intent.putExtra("package", getPackageName());
intent.putExtra("style", R.style.AppTheme);
startActivity(intent);

从我正在使用的其他应用程序

if(customization.getKeys().getString(Global.LINK_PACKAGE) == null) {
            customization = null;
        }else{
            Resources resources = getPackageManager().getResourcesForApplication(customization.getKeys().getString(Global.LINK_PACKAGE));
            container.setBackgroundColor(resources.getColor(customization.getKeys().getInt(Global.LINK_BACKGROUND_COLOR)));
            setTheme();//How can I get the style?
        }

其中 customization.getKeys() 是我传递的键。

1个回答

0

请记住,两个应用程序之间的R类可以具有相同的名称变量,但具有不同的值。我不建议在应用程序之间传递R值


不推荐吗?这是大忌。 - ci_
哈哈,我知道XD,这就是为什么我将变量和包名传递给其他应用程序,以便我可以通过放置包来获取资源。@ci_ - Rudy_TM
@Rudy_TM 哦,我现在明白了。你尝试过使用 resources.newTheme() 然后在返回的 Resources.Theme 对象上调用 applyStyle(resId, force) 吗?请参见 http://developer.android.com/reference/android/content/res/Resources.Theme.html#applyStyle(int, boolean) - ci_
我已经尝试过了,但我从另一个应用程序传递的resId总是显示“未找到”。我的drawable或其他内容都没有问题,只有这个小鬼。@ci_ - Rudy_TM
@Rudy_TM 你能把你尝试过的内容添加到问题中吗? - ci_

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接