简体   繁体   English

如何在Android Studio中创建最近使用过的列表

[英]How to create Most Recently Used list in android studio

Im new to app building and im building an application which stores a profile and data. 我是应用程序构建和构建存储配置文件和数据的应用程序的新手。 i want to add an activity where i can display a list of the most recently viewed profiles. 我想添加一个活动,在其中我可以显示最近查看的配置文件的列表。 Where do i start??? 我从哪里开始???

When viewing profile add timestamp to it. 查看配置文件时,请添加时间戳记。 And when displaying profiles sort them by timestamp you created. 在显示配置文件时,按您创建的时间戳对其进行排序。

You can get the timestamp when viewing profile, and store it to profiles table in an additional column in your database. 您可以在查看概要文件时获得时间戳记,并将其存储到数据库中其他列中的概要文件表中。 Then when you getting the list of profiles just sort them by column timestamp and show in given way. 然后,当您获得配置文件列表时,只需按列时间戳对其进行排序并以给定的方式显示。

To access timestamp you can use next code snippet: 要访问时间戳,您可以使用下一个代码段:

long timestamp = new Date().getTime();

Just call it when opening profile and store received value to the database if the value already exists - just update it. 只需在打开配置文件时调用它,并将接收到的值存储到数据库(如果该值已经存在)即可-只需对其进行更新即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM