如何使用数据库开发具有文本和图像的章节内容的书籍应用程序
How to develop book application with chapter content that has text and images using database
如以下另一个应用程序的屏幕截图示例所示,实现在章节中包含文本和图像的图书应用程序的最佳方式是什么。
我希望能够为我的应用程序生成以下内容,而无需将字符串硬编码到文本视图中,我希望能够从数据库中检索数据。
根据您的评论,我分享我的观点:- (如果您必须使用数据库和本机方式实现)
Table 结构为:-
- id => 整数
- chapter_id => 整数
- 数据 => 文本(包含图片路径和格式化文本字符串。)
- 类型 => 枚举('text','image')
并且您可以根据需要添加更多列。
因此,您需要触发如下查询:-
SELECT * From table_name WHERE chapter_id=9 order by id ASC.
Note:- You need to take care of inserting data, that you have to add
chapter data sequentially.
因此使用查询您可以获取模型数组中的所有数据(模型与您的table结构相同。)
然后使用Recycler 视图,您可以使用您的类型(图像/文本)显示多个视图。
据此
I have done this using HTML method. What I did is I created HTML files
for all the pages, then zipped all the pages. After that unzipped it
into android file system then using WebView I am able to view all the
pages like a book app does. I have added next page, previous page, and
search button also.
我最好的建议是将这些章节存储为 HTML 文件并使用这两个库之一显示它们 noties + MarkdownView
我自己之前使用过此策略来显示带有 HTML 响应的长内容,其中包括 HTML.
中的表格图像和样式
如以下另一个应用程序的屏幕截图示例所示,实现在章节中包含文本和图像的图书应用程序的最佳方式是什么。
我希望能够为我的应用程序生成以下内容,而无需将字符串硬编码到文本视图中,我希望能够从数据库中检索数据。
根据您的评论,我分享我的观点:- (如果您必须使用数据库和本机方式实现)
Table 结构为:-
- id => 整数
- chapter_id => 整数
- 数据 => 文本(包含图片路径和格式化文本字符串。)
- 类型 => 枚举('text','image')
并且您可以根据需要添加更多列。
因此,您需要触发如下查询:-
SELECT * From table_name WHERE chapter_id=9 order by id ASC.
Note:- You need to take care of inserting data, that you have to add chapter data sequentially.
因此使用查询您可以获取模型数组中的所有数据(模型与您的table结构相同。)
然后使用Recycler 视图,您可以使用您的类型(图像/文本)显示多个视图。
据此
I have done this using HTML method. What I did is I created HTML files for all the pages, then zipped all the pages. After that unzipped it into android file system then using WebView I am able to view all the pages like a book app does. I have added next page, previous page, and search button also.
我最好的建议是将这些章节存储为 HTML 文件并使用这两个库之一显示它们 noties + MarkdownView
我自己之前使用过此策略来显示带有 HTML 响应的长内容,其中包括 HTML.
中的表格图像和样式