-
Notifications
You must be signed in to change notification settings - Fork 8
/
P29.kt
43 lines (38 loc) · 1.5 KB
/
P29.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
package alpha.dex.one
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.widget.Toolbar
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var toolbar = findViewById<Toolbar>(R.id.toolbar)
toolbar.setTitle("ToolBar Example")
toolbar.setLogo(R.drawable.splash_logo)
setSupportActionBar(toolbar) //replace toolbar as an ActionBar
toolbar.setNavigationOnClickListener {
Toast.makeText(this, "Back Arrow", Toast.LENGTH_LONG).show()
}
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_toolbar, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id: Int = item.itemId
if (id == R.id.action_settings) {
Toast.makeText(applicationContext, "Settings Menu", Toast.LENGTH_LONG).show()
return true
} else if (id == R.id.action_email) {
Toast.makeText(applicationContext, "Email", Toast.LENGTH_LONG).show()
return true
} else if (id == R.id.action_add) {
Toast.makeText(applicationContext, "Add", Toast.LENGTH_LONG).show()
return true
}
return super.onOptionsItemSelected(item)
}
}