-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathP27.kt
31 lines (26 loc) · 885 Bytes
/
P27.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
package alpha.dex.dexsix
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.PopupMenu
import android.widget.Toast
class Popup : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_popup)
val btn = findViewById<Button>(R.id.btnShow)
btn.setOnClickListener {
val popup = PopupMenu(this, btn)
popup.menuInflater.inflate(R.menu.popupmenu, popup.menu)
popup.setOnMenuItemClickListener {
Toast.makeText(
applicationContext,
"You Clicked : " + it.title, Toast.LENGTH_LONG
)
.show()
true
}
popup.show()
}
}
}