-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopNavigationButtons.kt
More file actions
47 lines (44 loc) · 1.53 KB
/
TopNavigationButtons.kt
File metadata and controls
47 lines (44 loc) · 1.53 KB
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
package com.example.aboutme
import android.annotation.TargetApi
import android.content.Context
import android.content.Intent
import android.os.Build
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat.startActivity
import kotlinx.android.synthetic.main.edit_buttons.view.*
import kotlinx.android.synthetic.main.top_navigation.view.*
//this is the compound view for the calendar and graphs buttons at the top of the activities
class TopNavigationButtons: ConstraintLayout {
//initialises class as the compound view handler
@JvmOverloads
constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : super(context!!, attrs, defStyleAttr) {
init(context)
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context!!, attrs, defStyleAttr, defStyleRes) {
init(context)
}
private fun init(context: Context?) {
View.inflate(context, R.layout.top_navigation, this)
//starts the appropriate activity when a button is clicked
calendarNavButton.setOnClickListener()
{
getContext().startActivity(Intent(context, Calendar::class.java))
}
graphsNavButton.setOnClickListener()
{
getContext().startActivity(Intent(context, Graphs::class.java))
}
}
}