I am taking an Android development course, I need help with one of the tasks. The essence of the task is this: You need to create an application that will count the number of points in a basketball game for two teams (A and B). For each team you need to make a scoreboard with buttons (3 points, 2 points, penalty), and by pressing the desired button, the application must add points (in accordance with the button). And I successfully coped with this. However, you must also add a reset button (reset) results. And here I sat on the reefs. Help plz. XML and JAVA codes attached to the question

package com.example.android.courtcounter; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { int scoreTeamA = 0; int scoreTeamB = 0; int refreshPoints = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } /** * Этот метод дает три очка команде А при нажатии на соответствующую кнопку **/ public void plusThreePoints(View View) { scoreTeamA = scoreTeamA + 3; displayForTeamA(scoreTeamA); } /** * Этот метод дает два очка команде А при нажатии на соответствующую кнопку **/ public void plusTwoPoints(View View) { scoreTeamA = scoreTeamA + 2; displayForTeamA(scoreTeamA); } /** * Этот метод дает одно очко команде А при нажатии на соответствующую кнопку **/ public void plusOnePoint(View View) { scoreTeamA = scoreTeamA + 1; displayForTeamA(scoreTeamA); } public void plusThreePointsB(View View) { scoreTeamB = scoreTeamB + 3; displayForTeamB(scoreTeamB); } public void plusTwoPointsB(View View) { scoreTeamB = scoreTeamB + 2; displayForTeamB(scoreTeamB); } public void plusOnePointB(View View) { scoreTeamB = scoreTeamB + 1; displayForTeamB(scoreTeamB); } /** * Этот метод объявляет вывод очков для команды А (1,2,3) вместо нуля **/ public void displayForTeamA(int score) { TextView scoreView = (TextView) findViewById(R.id.team_a_score); scoreView.setText(String.valueOf(score)); } /** * Этот метод объявляет вывод очков для команды Б(1,2,3) вместо нуля **/ public void displayForTeamB(int score) { TextView scoreView = (TextView) findViewById(R.id.team_b_score); scoreView.setText(String.valueOf(score)); } <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.android.courtcounter.MainActivity"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:gravity="center" android:text="@string/Team_A" /> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:id="@+id/team_a_score" android:text="@string/_0" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/_3_Points" android:onClick="plusThreePoints" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/_2_points" android:onClick="plusTwoPoints" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/free_throw" android:onClick="plusOnePoint" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:gravity="center" android:text="@string/team_b" /> <TextView android:id="@+id/team_b_score" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/_0" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/_3_Points" android:onClick="plusThreePointsB" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/_2_points" android:onClick="plusTwoPointsB" /> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="8dp" android:text="@string/free_throw" android:onClick="plusOnePointB" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" android:layout_gravity="center_horizontal" android:gravity="bottom"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Refresh" android:onClick="refreshPoints" /> </LinearLayout> </LinearLayout> 

    1 answer 1

    And why can't you actually do this?)

     public void Reset(View View) { scoreTeamA = 0; scoreTeamB = 0; displayForTeamA(scoreTeamA); displayForTeamB(scoreTeamB); } 

    For a more specific answer, please attach a residual code or reformulate the question.

    • God, how stupid I am! Thanks a lot! - Georgy Pliev
    • one
      If I really helped, then mark the answer as the best please) - Eugene Lezov