Created
July 28, 2021 14:36
-
-
Save Draketheb4dass/11815592c8499fecb1da4d61a7bd2e46 to your computer and use it in GitHub Desktop.
Revisions
-
Draketheb4dass created this gist
Jul 28, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ 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 }