Home>

I am creating a quiz app at androistudio.

In the layout, we implemented a function that uses the button class's onClick method (specified method name is checkAnswer) to make a correct/incorrect judgment when a button is pressed.

However, since it is a code learned from a person, there are some parts that I wrote without understanding.

That is the argument View, view of the onClick method.

     public void checkAnswer (View view) {
        Button answerBtn = findViewById (view.getId ());
 String answerTxt = answerBtn.getText (). ToString ();
        String notice;// Used while creating a dialog.
        if (answerTxt.equals (rightAnswer)) {
            notice = "correct answer";
            rightCount ++;
            Continuous ++;

            if (Continuous>1) {
                notice = Continuous + "Continuous correct answer";
            }
        } else {
            Continuous = 0;
            notice = "Sorry!";
        }

The first question is the meaning of the argument View view.

And when you import

import android.view.View;
import android.widget.Button;


It is a point that becomes. I hypothesized that there is a view class in the inheritance destination of the View class, and there is a Button class in the inheritance destination, but it seems that it is different.

I would appreciate it if you could teach me these two mysterious points.