-
Notifications
You must be signed in to change notification settings - Fork 1
/
BookingActivity.kt
71 lines (47 loc) · 2.43 KB
/
BookingActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.example.booktrain
import android.app.Activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View.inflate
import android.widget.ArrayAdapter
import android.widget.Spinner
import android.widget.Toast
import com.example.booktrain.databinding.ActivityBookingBinding
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
class BookingActivity : AppCompatActivity() {
//private lateinit var binding : ActivityBookingBinding
//private lateinit var database : DatabaseReference
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//binding = ActivityBookingBinding.inflate(layoutInflater)
//setContentView(binding.root)
setContentView(R.layout.activity_booking)
//Accessing the list items:
val train_types = resources.getStringArray(R.array.train_types)
//Accessing the spinner
val spinner = findViewById<Spinner>(R.id.type_drop_down)
if (spinner != null){
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, train_types)
spinner.adapter = adapter
/*binding.next.setOnClickListener{
val currentLocation = binding.currLocation.text.toString()
val currentStation = binding.currStation.text.toString()
val destination = binding.dest.text.toString()
val trainTypeSelected = binding.typeDropDown.isSelected.toString()
database = FirebaseDatabase.getInstance().getReference("booktrain")
//val bookinginfo = bookings(currentLocation, currentStation, destination, trainTypeSelected)
//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
database.child(currentLocation).setValue(bookinginfo).addOnSuccessListener {
binding.currLocation.text.clear()
binding.currStation.text.clear()
binding.dest.text.clear()
//binding.typeDropDown.isSelected.clear()
Toast.makeText(this, "Successfully Saved!", Toast.LENGTH_SHORT).show()
}.addOnFailureListener{
Toast.makeText(this, "Failed!", Toast.LENGTH_SHORT).show()
}*/
}
}
}