Xml section
       
        <RadioGroup    android:id="@+id/radio"   
 android:layout_width="match_parent"    
android:layout_height="match_parent"    
android:orientation="horizontal"    
android:layout_marginTop="2dp"    
android:layout_marginLeft="10dp">    
<RadioButton        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:text="Good"/>    
<RadioButton        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:text="Bad"/>
    </RadioGroup>
        
 
kotlin.kt
       
           button.setOnClickListener { 
    val sid=radio.checkedRadioButtonId    
     val rbtn=findViewById<RadioButton>(sid)
    Toast.makeText(this,rbtn.text,Toast.LENGTH_SHORT).show()}
        
 

 
No comments:
Post a Comment