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

  • Home
  • SEARCH
  • 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 7769125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:05:04+00:00 2026-06-01T16:05:04+00:00

I am developing an quiz based app in that when the user clicks any

  • 0

I am developing an quiz based app in that when the user clicks any of the options it should the a suitable messages such as “your ans is correct” ,”your ans is wrong”.What i wanted is

 1. how to display that sort of messages ?or is it the only way to display such msgs ?
 2. If the user clicks wrong option the it should show the correct answer as well as the msg

here is what i have done so far but its not working giving force close!!!


public void onClick(View v) 
    {
        // TODO Auto-generated method stub
        switch (v.getId()) 
        {
        case R.id.button1:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) 
            {
                displayAnswer();

            }
            else
            {
                errorAnswer();

            }

            break;
        case R.id.button2:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) 
            {
                displayAnswer();
            }
            else
            {
                errorAnswer();

            }
            break;

        case R.id.button3:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) 
            {
                displayAnswer();
            }
            else
            {
                errorAnswer();

            }
            break;

        case R.id.button4:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) 
            {
                displayAnswer();
            }
            else
            {
                errorAnswer();


            }
            break;

        case R.id.btn_next:
//          lyt_ans.setVisibility(View.GONE);
//          lyt_quest.setVisibility(View.VISIBLE);
            prev = counter;
            counter += 1;

            if (counter >= SIZE) 
            {
                Collections.shuffle(quizIndexList);
                counter = 0;
            }
            getInfoFromDB(quizIndexList.get(counter));
            reLoad();

            break;

        case R.id.btn_bck:
                getInfoFromDB(quizIndexList.get(prev));
                    reLoad();
//          counter --;




        }
    }

    private void errorAnswer() 
    {
        Toast toast = new Toast(getApplicationContext());
        toast.setDuration(SIZE);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.setText("your answer is wrong");
        // TODO Auto-generated method stub

    }

    private void displayAnswer() {

        // TODO Auto-generated method stub
        lyt_quest = (LinearLayout) findViewById(R.id.lyt_quest);
        lyt_ans = (LinearLayout) findViewById(R.id.lyt_ans);
        lyt_quest.setVisibility(View.VISIBLE);
        lyt_ans.setVisibility(View.VISIBLE);
//      TextView txt1 = null;
        Toast toast = new Toast(getApplicationContext());
        toast.setDuration(SIZE);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.setText("Your answer is correct!!");
    }

Any help is appreciable.

  • 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-01T16:05:05+00:00Added an answer on June 1, 2026 at 4:05 pm

    why don’t you use

    Toast.makeText(getApplicationContext(), "Your message", Toast.LENGTH_SHORT).show();
    

    What you have written in your code will give you an error saying This toast was never created using Toast.makeText(). So it is better for you to use this method.

    If you want to use custom toast message, then one thing is compulsory what you have not done in your code. After creating your toast object, you have to set the view to that toast using setView(your inflated layout object). and then you have to invoke toast.show() at last. But remember, you have to get the inflated layout and pass it to setView().

    For more about custom toast see this link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an quiz based app and i wanted to know how i
I am developing a quiz based app. The quiz contains 1 question and 4
I'm developing an iPhone app. I need to create a Quiz application that has
I am developing an quiz based application. I wanted to know like, how can
I'm developing an Android app which is a quiz. On the other hand, I'm
The web application that I am developing right now has something called quiz engine
I am developing HTML5 css3 & js based game. So i want everything should
ok i am developing a quiz ... the question's options ... so i am
The web application that I am developing right now has something called quiz engine
I'm developing an app, which be be a game/quiz type application for testing a

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.