简体   繁体   English

android studio的各项活动如何使用数据?

[英]how to use data in every activity in android studio?

I am new to android studio.我是 android 工作室的新手。
i am trying to make a app which is a simple guessing game.我正在尝试制作一个简单的猜谜游戏应用程序。
in this app every player will enter his name and two numbers.在此应用程序中,每个玩家都将输入他的名字和两个数字。
after every player submits their entries all players will try guessing what other players have entered.在每个玩家提交他们的条目后,所有玩家都会尝试猜测其他玩家输入的内容。
my problem is that i dont know how to manage data in this app.我的问题是我不知道如何管理这个应用程序中的数据。
like storing all entries in list and using them later as condition.就像将所有条目存储在列表中并在以后将它们用作条件一样。

i tried using data class and data object but dont know how to really use it?我尝试使用数据 class 和数据 object 但不知道如何真正使用它?

As beginner, you can just create public singleton (object in kotlin), and read/write data to this singleton from each activity on your project作为初学者,您只需创建 public singleton(kotlin 中的对象),然后从您项目的每个活动中向此 singleton 读/写数据

https://en.wikipedia.org/wiki/Singleton_pattern https://en.wikipedia.org/wiki/Singleton_pattern

https://kotlinlang.org/docs/object-declarations.html#object-declarations-overview https://kotlinlang.org/docs/object-declarations.html#object-declarations-overview

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

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