制作动态表格(最好的方法)

时间:2022-01-06 15:51:12

I have to develop an application for an Android Tablet. This will do the following:

我必须开发Android平板电脑的应用程序。这将执行以下操作:

I will connect to a web service to retrieve a dynamic list of forms. Those forms must be downloaded to fill them offline. When one or more forms are filled, and application is online, user can send them to a server clicked on a button.

我将连接到Web服务以检索动态的表单列表。必须下载这些表单才能脱机填写。当填写一个或多个表单并且应用程序在线时,用户可以将它们发送到单击按钮的服务器。

Those forms will be dynamic. There isn't a predefined form. And they will have one or more pictures attached.

这些形式将是动态的。没有预定义的表单。他们将附上一张或多张照片。

My problem is that I don't know how to do it.

我的问题是我不知道该怎么做。

I've thought:

我想:

  1. I could send a form as set of fields and their types. Once I download xml from web service, I will have to rebuild it to show it to user.

    我可以发送一个表单作为字段及其类型。一旦我从Web服务下载xml,我将不得不重建它以向用户显示它。

  2. Send an html page with a form.

    发送带有表单的html页面。

  3. HTML5 (with PhoneGap).

    HTML5(使用PhoneGap)。

  4. ...?

    ...?

I think second option is the best. What do you think?

我认为第二种选择是最好的。你怎么看?

Once user has filled a form, how can I save its data? If I'm using a web page, I think I can save it as CSV.

用户填写表单后,如何保存其数据?如果我正在使用网页,我想我可以将其保存为CSV。

First option will be an android native interface, so I could save it on SQLite or as txt file. How can I store those forms filled?

第一个选项是一个android原生接口,所以我可以将它保存在SQLite或txt文件中。如何存储填写的表格?

And then, when user comes back online, how can I send a txt file and image through a web service?

然后,当用户重新上线时,如何通过Web服务发送txt文件和图像?

If you have another approach, you are welcome to share it.

如果您有其他方法,欢迎您分享。

1 个解决方案

#1


3  

I would go for option 1 since it has a more native feel...

我会选择1,因为它有更原生的感觉......

Fast brainstorm: You could create a DB with table: Forms (id, name ...), FormItems (id, formid, name, type, order ...), Data (id, FormItemsid, EntryId, value ...), Entries (id, dateadded, sent ...)

快速头脑风暴:您可以创建一个包含表格的数据库:Forms(id,name ...),FormItems(id,formid,name,type,order ...),Data(id,FormItemsid,EntryId,value ...) ,条目(id,dateadded,sent ...)

When you want to show a form you open an activity and you loop through all FormItems with that formid (you can have a LinearLayout (orientation: vertical) and addView for every item)

当你想要显示一个表单时,你打开一个活动,然后使用该formid遍历所有FormItems(你可以有一个LinearLayout(方向:垂直)和每个项目的addView)

When you fill in a form a new Entry is created and you loop through your formitems and put the entred text in Data

当您填写表单时,将创建一个新条目,然后循环您的表单项并将所需文本放入数据中

When you go online you check what entries aren't sent yet and you send those items

当您上线时,检查哪些条目尚未发送,您发送这些项目

Hope this was helpful!

希望这有用!

#1


3  

I would go for option 1 since it has a more native feel...

我会选择1,因为它有更原生的感觉......

Fast brainstorm: You could create a DB with table: Forms (id, name ...), FormItems (id, formid, name, type, order ...), Data (id, FormItemsid, EntryId, value ...), Entries (id, dateadded, sent ...)

快速头脑风暴:您可以创建一个包含表格的数据库:Forms(id,name ...),FormItems(id,formid,name,type,order ...),Data(id,FormItemsid,EntryId,value ...) ,条目(id,dateadded,sent ...)

When you want to show a form you open an activity and you loop through all FormItems with that formid (you can have a LinearLayout (orientation: vertical) and addView for every item)

当你想要显示一个表单时,你打开一个活动,然后使用该formid遍历所有FormItems(你可以有一个LinearLayout(方向:垂直)和每个项目的addView)

When you fill in a form a new Entry is created and you loop through your formitems and put the entred text in Data

当您填写表单时,将创建一个新条目,然后循环您的表单项并将所需文本放入数据中

When you go online you check what entries aren't sent yet and you send those items

当您上线时,检查哪些条目尚未发送,您发送这些项目

Hope this was helpful!

希望这有用!