我可以从其他应用程序获取布局但不能使用图像(可绘制)
I can get layout from other applications but NOT with image(drawable)
我想在我的应用程序保护器应用程序中添加主题功能,但我遇到了一个大问题。
我可以从其他应用程序获取布局,但布局不显示可绘制对象
(例如背景、Src、...)
(例如,如果我使用背景为 "background.png" 的布局制作主题应用程序,主应用程序可以获得主题应用程序的布局但没有背景!!)
↓↓代码
Resources theme = null;
try
{
theme = getPackageManager().getResourcesForApplication(nowTheme);
//nowTheme = packageName
}
catch (PackageManager.NameNotFoundException e)
{
}
if (theme != null)
{
int resID = theme.getIdentifier("theme" , "layout", nowTheme);
mView = mInflater.inflate(theme.getLayout(resID), null);
}
else
{
mView = mInflater.inflate(R.layout.theme_default, null);
dataConverter.dataPut(this, "default", SP_LOCATION_THEME, "theme");
//dataConverter = sharedpreferences
Toast.makeText(getApplicationContext(), "Error", 3000).show();
}
我是不是代码有误? :(
p.s 我认为这是因为 "R.drawable" 用于主题应用程序的背景
如果要显示背景,布局必须在其中声明背景可绘制资源。在此处检查布局或 post 您的主题布局。
我想在我的应用程序保护器应用程序中添加主题功能,但我遇到了一个大问题。
我可以从其他应用程序获取布局,但布局不显示可绘制对象 (例如背景、Src、...) (例如,如果我使用背景为 "background.png" 的布局制作主题应用程序,主应用程序可以获得主题应用程序的布局但没有背景!!)
↓↓代码
Resources theme = null;
try
{
theme = getPackageManager().getResourcesForApplication(nowTheme);
//nowTheme = packageName
}
catch (PackageManager.NameNotFoundException e)
{
}
if (theme != null)
{
int resID = theme.getIdentifier("theme" , "layout", nowTheme);
mView = mInflater.inflate(theme.getLayout(resID), null);
}
else
{
mView = mInflater.inflate(R.layout.theme_default, null);
dataConverter.dataPut(this, "default", SP_LOCATION_THEME, "theme");
//dataConverter = sharedpreferences
Toast.makeText(getApplicationContext(), "Error", 3000).show();
}
我是不是代码有误? :(
p.s 我认为这是因为 "R.drawable" 用于主题应用程序的背景
如果要显示背景,布局必须在其中声明背景可绘制资源。在此处检查布局或 post 您的主题布局。