-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathP12.kt
72 lines (60 loc) · 2.47 KB
/
P12.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
package com.example.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.*
class DropDownEx : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_drop_down_ex)
val editName = findViewById<EditText>(R.id.editName)
val editPass = findViewById<EditText>(R.id.editPass)
val editEmail = findViewById<EditText>(R.id.editEmail)
val editDate = findViewById<EditText>(R.id.editDate)
val editPhone = findViewById<EditText>(R.id.editPhone)
val btn = findViewById<Button>(R.id.btn_submit)
val res = findViewById<TextView>(R.id.res)
var spinner = findViewById<Spinner>(R.id.dropdown)
var course = arrayOf("B-tech", "B.C.A.", "B.Sc.", "M.C.A.", "B.B.A.", "M.B.A.")
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 t2 = editPass.text.toString()
val t3 = editEmail.text.toString()
val t4 = editDate.text.toString()
val t5 = editPhone.text.toString()
if (t1.isEmpty() || t2.isEmpty() ||
t3.isEmpty() || t4.isEmpty() || t5.isEmpty()
) {
res.text = "Enter All The Values"
} else {
res.text = " Entered Values are : \n " +
"Name : ${t1} \n" +
"Password : ${t2} \n" +
"Email : ${t3} \n" +
"Date : ${t4} \n" +
"Phone No. : ${t5} \n " +
"Course : ${option}"
}
}
}
}
}