Funris
Funris

Reputation: 51

Dynamically create new variables or work with an array

So I'm developer and currently working on an android to-do list app.

I'm looking for a way to store the date entered by the user:

Is there is a way to create variables dynamically ? (e.g. task1, task2, etc..)

Or should I work with 3 arrays for the time, title, description.

For example:

Time = ["5pm","4:15pm","6:30am"]
Title = ["Pick up the kids","meet Ammy"]

Thank you.

Upvotes: 0

Views: 60

Answers (1)

Strelok
Strelok

Reputation: 51441

How about creating a class Task and keep them in a list?

data class Task(val title: String, val time: String)

val tasks = listOf(Task(“Meet Amy”, “5pm”), Task(“Pick up kids”, “3pm”)

Upvotes: 2

Related Questions