forked from deveshp007/Android-App-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP15_b.kt
75 lines (63 loc) · 2.45 KB
/
P15_b.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
72
73
74
75
package alpha.beta.dex_three
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.*
class MainActivity2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
val res = findViewById<TextView>(R.id.res)
val ress = findViewById<TextView>(R.id.ress)
var spinner = findViewById<Spinner>(R.id.dropdown)
val editName = findViewById<EditText>(R.id.editName)
val editEmail = findViewById<EditText>(R.id.editEmail)
val editAdd = findViewById<EditText>(R.id.editAdd)
val editPhone = findViewById<EditText>(R.id.editPhone)
val btn = findViewById<Button>(R.id.btn_submit)
var txt = intent.getStringExtra("name")
res.text = "Please fill the following details.\n" +
"Your ${txt} is added to cart."
var course = arrayOf("Regular", "Medium", "Large")
var option = ""
if (spinner != null) {
val adapter = ArrayAdapter(
this,
android.R.layout.simple_spinner_item, course
)
spinner.adapter = adapter
spinner.onItemSelectedListener = object :
AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>,
view: View, position: Int, id: Long
) {
option = course[position]
}
override fun onNothingSelected(p0: AdapterView<*>?) {
}
}
}
btn.setOnClickListener()
{
val t1 = editName.text.toString()
val t3 = editEmail.text.toString()
val t4 = editAdd.text.toString()
val t5 = editPhone.text.toString()
if (t1.isEmpty() ||
t3.isEmpty() || t4.isEmpty() || t5.isEmpty()
) {
ress.text = "Enter All The Values"
} else {
val intent = Intent(this,MainActivity3::class.java)
intent.putExtra("name",t1)
intent.putExtra("email",t3)
intent.putExtra("date",t4)
intent.putExtra("phone",t5)
intent.putExtra("size",option)
startActivity(intent)
}
}
}
}