I am creating an android application .. in my app.. one of the activity contains 2 radio buttons..i have 2 questions for it...

How to select only one radio button at a time, what code will be written?
How to decrease the size of the radio icon (Circular icon only, not text)?
I can show u my xml file..

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/textView3"
        style="@style/headings"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="30dp"
        android:text="Basic Electrical Engineering"
        android:textSize="25sp" />
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Number of Sessions"
        android:textSize="20sp" />
    <RadioButton
        android:id="@+id/radioButton1"
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="1"
        android:textSize="16sp" />
    <RadioButton
        android:id="@+id/RadioButton01"
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="2"
        android:textSize="16sp" />
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="5dp"
        android:paddingTop="15dp"
        android:text="Session(s) Duration"
        android:textSize="20sp" />
    <EditText
        android:id="@+id/editText1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="example: 2 hours" >
        <requestFocus />
    </EditText>
    <TextView
        android:id="@+id/TextView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="5dp"
        android:paddingTop="15dp"
        android:text="Room"
        android:textSize="20sp" />
    <EditText
        android:id="@+id/EditText01"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="example: A" />
    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="clip_vertical"
        android:gravity="center_vertical"
        android:text="Begin Attendance" />
</LinearLayout>
</ScrollView>

Encaupsulate radio buttons with radio group, that is radio group purpose

can you follow this tutorial

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <RadioGroup
        android:id="@+id/rgsex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >  
    <RadioButton
        android:id="@+id/rdmal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/l1" ></RadioButton>
    <RadioButton 
        android:id="@+id/rdfel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/l2"
        android:checked="true"
        ></RadioButton>
    </RadioGroup>
    <Button 
        android:id="@+id/btndis"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/l3"
        ></Button>
</LinearLayout>






package com.example.radiobuttonexample;

import android.os.Bundle;
import android.app.Activity;
import android.view.*;
import android.widget.*;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {
    //RadioButton rb1,rb2;
    RadioButton rbsex;
    RadioGroup rgsex;
    Button btndisplay;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addListenerOnButton();
    }
    public void addListenerOnButton(){  
        //rb1=(RadioButton)findViewById(R.id.rdmal);
        //rb2=(RadioButton)findViewById(R.id.rdfel);
        rgsex=(RadioGroup)findViewById(R.id.rgsex);
        btndisplay=(Button)findViewById(R.id.btndis);
        btndisplay.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
        int selectedId=rgsex.getCheckedRadioButtonId();
        rbsex=(RadioButton)findViewById(selectedId);
        StringBuffer result=new StringBuffer();
        result.append(rbsex.getText());
        Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
            //if(rb1.isChecked())result.append(rb1.getText());
            //else if(rb2.isChecked()) result.append(rb2.getText());
        //  Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
            }
        });
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

thank u so much for sharing my studied lesson in android development field.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.