0% found this document useful (0 votes)
23 views4 pages

Ex - No.3 (Usage of Radio Button)

The document outlines the procedure to develop an Android application that utilizes Radio Buttons. It includes steps for creating a project, designing the layout with RadioGroup and RadioButtons, and coding the functionality to display the selected Radio Button text in a Toast message upon button click. The application was successfully created and tested.

Uploaded by

raguljo1421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Ex - No.3 (Usage of Radio Button)

The document outlines the procedure to develop an Android application that utilizes Radio Buttons. It includes steps for creating a project, designing the layout with RadioGroup and RadioButtons, and coding the functionality to display the selected Radio Button text in a Toast message upon button click. The application was successfully created and tested.

Uploaded by

raguljo1421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

[Link].

3: Develop an application that uses the Radio Button


Aim:
To develop an application that uses the Radio Button
Procedure:
Step 1: Create new project
Step 2: Click xml file (activity_main.xml)
Step 3: Click design option and design your application using (RadioGroup, RadioButtons
and 1 Button)

Step 4: Now, open up the activity java file ([Link]).


Step 5: Write the code for radio button selection.

Step 6: Add the click listener to the Display button.


Step 7: When that button has been clicked, selected radio button text will be displayed in the
Toast.

Step 8: End.
Code:
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


RadioButton radioButton1, radioButton2, radioButton3, radioButton4;
String selectedSubject;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
radioButton1 = (RadioButton) findViewById([Link].radioButton1);
radioButton2 = (RadioButton) findViewById([Link].radioButton2);
radioButton3 = (RadioButton) findViewById([Link].radioButton3);
radioButton4 = (RadioButton) findViewById([Link].radioButton4);
submit = (Button) findViewById([Link].button3);
[Link](new [Link]() {
@Override
public void onClick(View v) {
if ([Link]()) {
selectedSubject = [Link]().toString();
} else if ([Link]()) {
selectedSubject = [Link]().toString();
} else if ([Link]()) {
selectedSubject = [Link]().toString();
} else if ([Link]()) {
selectedSubject = [Link]().toString();
}
[Link](getApplicationContext(), selectedSubject,
Toast.LENGTH_LONG).show();
}
});
}
}
Output:

Result:
This Mobile Application has been created and tested successfully.

You might also like