创建画面和数据访问层在Android底层动态 [英] Creating screens and underlying data access layer dynamically on Android
问题描述
我想允许用户创建自定义界面动态通过的运行的,即一切都应该在App做在手机上从现有的字段集选择。
I want to allow the user to create "custom screens" dynamically by selecting from a existing set of fields at runtime i.e., everything should be done on App on the phone.
例如 - 现有油田集= {名称,位置,图片,年龄}
。
For example - existing set of fields = {name, location, picture, age}
.
用户A要创建域的名称,位置和年龄的一个新的屏幕。
User A wants to create a new screen with fields name, location and age.
和用户B都想拥有,只有名字和照片的屏幕。
and User B wants to have a screen with only name and picture.
这些画面应该是持久的,并应能够保存,查询和在手机上的本地数据库信息进行编辑。
These screens should be persistent and should be able to save, query and edit information in a local database on the phone.
有关如何实现这一点在Android将成为AP preciated任何帮助。
Any help about how to achieve this in Android will be appreciated.
感谢。
推荐答案
您将要在Java中动态创建这些视图(不使用布局)。我会放在一起某种XML模式,然后将其保存无论是在DB或设备上。然后,你可以做的事情,如:
You will want to create these views dynamically in Java (not using layouts). I would put together some sort of XML schema, and then save it either in the DB or on the device. Then you could do things such as:
//pseudo-code
while (xmlDoc isn't empty) {
View v = null;
if (XML says to create a text view) {
v = new TextView(this);
...
}
else if (XML says to create an ImageView) {
v = new ImageView(this);
...
}
add v to the LinearLayout or whatever type of root view will be passed to setContentView().
这篇关于创建画面和数据访问层在Android底层动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!