Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:24:29+00:00 2026-06-04T09:24:29+00:00

Hello guys I need to make a simple android quiz. Well what I’ve done

  • 0

Hello guys I need to make a simple android quiz. Well what I’ve done so for is these with the help of other examples online.

MyOSIActivity.java

package com.mns.mp;


import tp.mns.mp.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class MyOSIActivity extends Activity {

    private RadioGroup radioAnswerGroup;
    private RadioButton radioAnswerButton;
    private Button btnSubmit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        addListenerOnButton();

    }

    public void addListenerOnButton() {

        radioAnswerGroup = (RadioGroup) findViewById(R.id.radioAnswer);
        btnSubmit = (Button) findViewById(R.id.btnSubmit);

        btnSubmit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                // get selected radio button from radioGroup
                int selectedId = radioAnswerGroup.getCheckedRadioButtonId();

                // find the radiobutton by returned id
                radioAnswerButton = (RadioButton) findViewById(selectedId);

                Toast.makeText(MyOSIActivity.this,
                        radioAnswerButton.getText(), Toast.LENGTH_SHORT).show();

            }

        });

    }
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

        <TextView
        android:id="@+id/Qn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:text="@string/Qn_1"
       />

    <RadioGroup
        android:id="@+id/radioAnswer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/radio_1" 
            android:checked="true" />

        <RadioButton
            android:id="@+id/radio2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/radio_2" />

         <RadioButton
            android:id="@+id/radio3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/radio_3" />

    </RadioGroup>

    <Button
        android:id="@+id/btnSubmit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btn_submit" />

</LinearLayout>

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="hello">Hello World, MyAndroidAppActivity!</string>
    <string name="app_name">MyAndroidApp</string>
    <string name="Qn_1"> Question 1: Acknowledgement, Sequencing, and Flow control are characteristics of which OSI layer?</string>
    <string name="radio_1">Layer 2</string>
    <string name="radio_2"> Layer 3</string>
    <string name="radio_3"> Layer 4</string>
    <string name="btn_submit">Submit</string>

</resources>

Ok now I’m trying to make the system compare the user answer with the correct answer after the user press submit button which in this case its Layer 4. Then if the user answer is wrong, the toast will reply to the user it is incorrect and show the correct answer. Where as if the user is correct then it will reply correct to the user. So I need to use if else but the thing is I am still not familiar with it. Ill appreciate if you guys give me guidances because I really need it. Thank you soo much 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:24:30+00:00Added an answer on June 4, 2026 at 9:24 am

    you can do this in so many ways…. if you know the id of the correct answer, you can do:

    if (selectedId==correctId){
        //show toast saying it is correct
    }
    else{
        //toast incorrect
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello guys i need small help in understanding file system of android Now in
Hello guys I'm stucked in a point and I need your help. I want
Hello everyone i need some help. I'm trying to make an application for mac
Hello guys I need a bit of help. As I am not very good
hello guys i need to sort some elements of integer in an integer array
Hello guys i need to capture the output of an external command, herefore I
Hello guys I need to pass a string array over to a setter that
Hello guys I am working on a prolog game and I need to write
Ok this is a continuation from this question: How to make a simple Hello
hello guys i need to use pure SQL queries for my database project at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.