Radio & CheckboxWidget

PHOTO EMBED

Thu Apr 14 2022 19:20:06 GMT+0000 (Coordinated Universal Time)

Saved by @anasrathore #kotlin

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RadioButton
                android:id="@+id/rb10Above"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="10-17"/>

            <RadioButton
                android:id="@+id/rb18Above"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="18-30"/>

            <RadioButton
                android:id="@+id/rb31Above"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="31-Above"/>
        </RadioGroup>

        <CheckBox
            android:id="@+id/cbTermsConditions"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/terms_conditions"/>

              
    override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
        showToast(p0?.getItemAtPosition(p2).toString())
    }

    override fun onNothingSelected(p0: AdapterView<*>?) {

    }

    fun onSignUpClicked(view: View) {
        executeSignUp()
    }
    private fun executeSignUp(){
        AlertDialog.Builder(this).apply {
            setTitle("Title")
            setMessage("RB 10 Above = ${rb10Above.isChecked}" +
                    "\nRB 18 Above = ${rb18Above.isChecked}" +
                    "\nRB 31 Above = ${rb31Above.isChecked}" +
                    "\n\nTerms & Conditions = ${cbTermsConditions.isChecked}")
            setPositiveButton("Ok") { dialogInterface, i ->
                dialogInterface.dismiss()
            }
            setNegativeButton("Cancel") { dialogInterface, i ->
                dialogInterface.dismiss()
            }
        }.create().show()
    }
content_copyCOPY