* has helped me tremendously with my projects. Thank you for that. Now here's my problem:
*对我的项目帮助很大。谢谢你。现在这是我的问题:
I've made an app for a company. This company has many customers who will be using the app. The company would like to customize the app layout per customer. They would like to change the background color of elements & button images, among other things.
我为一家公司做了一个应用程序。该公司有许多客户将使用该应用程序。该公司希望为每个客户定制应用布局。他们希望改变元素和按钮图像的背景颜色等。
Now, I'd like to:
现在,我想:
- download a customized xml layout from their server
- download customized button images etc.
从他们的服务器下载自定义的xml布局
下载自定义按钮图像等
(Both of these are currently loaded from resources.) Then:
(这些都是从资源加载的。)然后:
- use those to style the app.
用这些来设计应用程序的风格。
So, the downloading won't be a problem. The storing of the data in the internal storage won't be a problem either. But.
所以,下载不会有问题。将数据存储在内部存储器中也不是问题。但。
How do I tell the app to use the customized xml layout, which can be found in the internal storage? Up until now I've used this.
如何告诉应用程序使用可在内部存储中找到的自定义xml布局?到目前为止,我已经习惯了这个。
setContentView(R.layout.activity_main);
Now, I want to set do the same, but based on an XML found in internal storage.
现在,我想设置相同的,但基于内部存储中找到的XML。
In addition, I'd like to load images for buttons etc. from the internal storage too, instead of from resources. Right now I use this:
另外,我也想从内部存储器加载按钮等的图像,而不是从资源加载。现在我用这个:
findViewById(R.id.button_x).setBackgroundResource(R.drawable.button02);
So, in short, my question is:
所以,简而言之,我的问题是:
Is there a way to achieve the functionality of the code above, but with files from the internal storage?
有没有办法实现上面代码的功能,但有内部存储的文件?
1 个解决方案
#1
2
probably you can create a XmlPullParser
from the file you downloaded, inflate it through the XmlPullParser
obect and pass it as paramter to setContentView
. doc for XmlPullParser is here. The inflate method you should use is here. I have never triedm, but teorically seems possible
可能你可以从你下载的文件中创建一个XmlPullParser,通过XmlPullParser对象对其进行膨胀,并将其作为参数传递给setContentView。 XmlPullParser的doc就在这里。你应该使用的膨胀方法就在这里。我从未尝试过,但似乎有可能
Edit:
A project of @RoundSparrowhilltx can be found here
可以在这里找到@RoundSparrowhilltx项目
#1
2
probably you can create a XmlPullParser
from the file you downloaded, inflate it through the XmlPullParser
obect and pass it as paramter to setContentView
. doc for XmlPullParser is here. The inflate method you should use is here. I have never triedm, but teorically seems possible
可能你可以从你下载的文件中创建一个XmlPullParser,通过XmlPullParser对象对其进行膨胀,并将其作为参数传递给setContentView。 XmlPullParser的doc就在这里。你应该使用的膨胀方法就在这里。我从未尝试过,但似乎有可能
Edit:
A project of @RoundSparrowhilltx can be found here
可以在这里找到@RoundSparrowhilltx项目