Created
July 28, 2021 14:36
-
-
Save Draketheb4dass/11815592c8499fecb1da4d61a7bd2e46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jephtecolin.kwii.ui.custom | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.ViewGroup | |
import android.widget.LinearLayout | |
import androidx.appcompat.widget.AppCompatCheckBox | |
import androidx.appcompat.widget.AppCompatTextView | |
import com.jephtecolin.kwii.R | |
class CheckboxCustom @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) { | |
private val root: ViewGroup | |
private val tvTitle: AppCompatTextView | |
private val tvPrice: AppCompatTextView | |
private val checkbox: AppCompatCheckBox | |
init { | |
inflate(context, R.layout.checkbox_custom, this) | |
root = findViewById(R.id.root) | |
tvTitle = findViewById(R.id.tvTitle) | |
tvPrice = findViewById(R.id.tvPrice) | |
checkbox = findViewById(R.id.checkbox) | |
checkbox.isChecked | |
root.setOnClickListener { | |
checkbox.toggle() | |
this.callOnClick() | |
} | |
} | |
fun setTitle(title: String) { | |
tvTitle.text = title | |
} | |
fun setPrice(price: String) { | |
tvPrice.text = price | |
} | |
fun isChecked(): Boolean = checkbox.isChecked | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment