How do you remove items from a list and then add them back?

So im making a hall pass app were basically students can put their name and destination and press button and starts counting how long it takes and come back and stores the data...I'm having a problem were I have a list of periods by default but not all teachers have all periods (due to conference periods and luch periods) so I made so teachers can choose what periods are listed according to their schedule and that is chosen in the settings screen and when they come to the main screen I tell the list picker to display the default list but to first check what periods are enabled or disabled in this case so it can take them out of the list which it does but when periods are reset back to default how can I add those periods back to that list?

From your description, I envision you need three lists:

  • a one dimensional list of all teacher names
  • a one dimensional list of all period names
  • a two dimensional table with each row containing a teacher-period-studentHallPassUser list
    • teacher
    • period
    • name of student currently using the hall pass for that teacher for that period (or blank)
    • start timestamp
    • end timestamp
1 Like

Well that actually not how its set up...student comes in and types their name and chooses a destination from a drop down and then clicks a button thats starts and timer and then another button when it comes back to stop it and then saves and the data in a tiny dB and displays it in the list viewer...what I'm trying to do is that I have a list of periods that is displayed by a list picker and teachers in the settings choose what periods are displayed depending on which periods they have classes on so which ever are disabled is taken off the list but let's say the teacher meses up taking off a period how do I added back so decided to add a reset button to bring the list back to default but since those periods are already taken off the list how do I bring them back? I'm using a global list for this BTW

When removing items from a list, add them to another list of removed items. Then select from the removed items list to add them back to the first list.

That make a lot of sense!!! Thank you!!! But one more thing...how do I maintain a specific order...for example I have period 1, period 2, and period 3. If I remove period 2 and added back wouldn't it be Period 1, period 3, and then period 2? How would I put back in order?

After returning an item to the list, sort the list. There are examples of bubble sorting for lists, or extensions to help with sorting. Your data would need to be alpha-numeric in order for the sorting to work.

Will try that! Thank you so much!

Here are some resources for lists: