ChildAdapter.kt
1.78 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
package com.example.vip
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.item_child.view.*
import kotlinx.android.synthetic.main.item_policyfield.view.*
class ChildAdapter(private val items: ArrayList<ChildItem>) :
RecyclerView.Adapter<ChildAdapter.ViewHolder>() {
override fun getItemCount() = items.size
override fun onBindViewHolder(holder: ChildAdapter.ViewHolder, position: Int) {
val item = items[position]
holder.apply {
bind(item)
itemView.tag = item
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
ChildAdapter.ViewHolder {
val inflatedView = LayoutInflater.from(parent.context)
.inflate(R.layout.item_child, parent, false)
return ChildAdapter.ViewHolder(inflatedView)
}
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
private var view: View = v
fun bind(item: ChildItem) {
view.circleformButton.text=item.numOfChild.toString()
view.childTextView.text=" 자녀 "+item.numOfChild.toString()
view.womanButton.setOnClickListener {
if(view.manButton.isChecked){
view.manButton.isChecked=false
}else{
}
}
view.manButton.setOnClickListener {
if(view.womanButton.isChecked){
view.womanButton.isChecked=false
}else{
}
}
}
}
}