SignInActivity.kt
4.26 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.example.vip
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_signin.*
class SignInActivity : AppCompatActivity() {
internal lateinit var viewpager : ViewPager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_signin)
testingButton.setOnClickListener {
var intent = Intent(this, PushingTestActivity::class.java)
startActivity(intent)
}
val policyFieldList = ArrayList<PolicyFieldItem>()
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image01)!!,
getString(R.string.title01)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image02)!!,
getString(R.string.title02)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image03)!!,
getString(R.string.title03)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image04)!!,
getString(R.string.title04)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image05)!!,
getString(R.string.title05)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image06)!!,
getString(R.string.title06)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image07)!!,
getString(R.string.title07)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image08)!!,
getString(R.string.title08)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image09)!!,
getString(R.string.title09)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image10)!!,
getString(R.string.title10)
)
)
val adapter = PolicyFieldAdapter(policyFieldList)
policyFieldRecyclerView.adapter = adapter
viewpager = findViewById(R.id.viewpager) as ViewPager
val viewpageradapter = ViewPagerAdapter(this)
viewpager.adapter = viewpageradapter
// 1. 툴바 사용 설정
setSupportActionBar(toolbar)
// 2. 툴바 왼쪽 버튼 설정
supportActionBar!!.setDisplayHomeAsUpEnabled(true) // 왼쪽 버튼 사용 여부 true
supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정
supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기
}
// 3.툴바 메뉴 버튼을 설정
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.main_menu, menu) // main_menu 메뉴를 toolbar 메뉴 버튼으로 설정
return true
}
// 4.툴바 메뉴 버튼이 클릭 됐을 때 콜백
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
// 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다.
when(item!!.itemId){
android.R.id.home->{ // 메뉴 버튼
Snackbar.make(toolbar,"Menu pressed",Snackbar.LENGTH_SHORT).show()
}
R.id.menu_search->{ // 검색 버튼
Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show()
}
}
return super.onOptionsItemSelected(item)
}
}