我卖书的应用程序,当用户买了一本书,一个pdf文件被下载到手机的内存中。我有两类书,pdf文件的名称有一个代码来识别它。
val purchasedBooks: ArrayList<String> = ArrayList()
val directoryFiles = context?.filesDir
val files = directoryFiles?.listFiles()
if (files != null) {
for (aFile in files) {
purchasedBooks.add(aFile.name)
}
}
purchasedBooks
:
[ssbook1.pdf, ssbook2.pdf, ssbook3.pdf, aabook1.pdf, aabook2.pdf]
val ssbooks = [ssbook1, ssbook2, ssbook3] // without .pdf
val aabooks = [aabook1, aabook2]
然后在回收视图中按部分显示:
________________
MY SS BOOK
________________
ssbook1
----------------
ssbook2
----------------
ssbook3
________________
MY AABOOK
________________
aabook1
----------------
aabook2
任何建议我都将不胜感激。