Last active
February 1, 2017 20:51
-
-
Save fragargon/cf55af159fa370f45b13bda7359e35d5 to your computer and use it in GitHub Desktop.
project ScoreKeeper main file created with AndroidStudio for this project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/activity_main" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.android.scorekeeper.MainActivity"> | |
<!-- own title bar --> | |
<TextView | |
android:id="@+id/appname" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="@drawable/football_banner" | |
android:gravity="center" | |
android:text="@string/app_name" | |
android:textColor="@android:color/black" | |
android:textSize="64sp" | |
android:textStyle="bold" /> | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:layout_marginTop="@dimen/activity_vertical_margin" | |
android:contentDescription="@string/desc" | |
android:src="@drawable/icone_ballon" /> | |
<!-- main GroupView --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="@dimen/activity_vertical_margin" | |
android:orientation="horizontal"> | |
<!-- GroupView TeamA col --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:orientation="vertical" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8"> | |
<TextView | |
android:id="@+id/TeamA" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/teamA" | |
android:textSize="@dimen/Text_size_team" /> | |
<!-- goal row--> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addGoalTeamA" | |
android:text="@string/goalTeam" /> | |
<TextView | |
android:id="@+id/scoreTeamA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scoreTeamA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
<!-- penalty row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addPenaltyTeamA" | |
android:text="@string/penaltyTeam" /> | |
<TextView | |
android:id="@+id/scorePenaltyA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scorePenaltyA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
<!-- corner row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addCornerTeamA" | |
android:text="@string/cornerTeam" /> | |
<TextView | |
android:id="@+id/scoreCornerA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scoreCornerA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
<!-- fault row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addFaultTeamA" | |
android:text="@string/faultTeam" /> | |
<TextView | |
android:id="@+id/scoreFaultA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scoreFaultA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
<!-- redcard row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addRedCardTeamA" | |
android:text="@string/redCardTeam" /> | |
<TextView | |
android:id="@+id/scoreRedCardTeamA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scoreRedCardA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
<!-- yellowcard row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addYellowCardTeamA" | |
android:text="@string/yellowCardTeam" /> | |
<TextView | |
android:id="@+id/scoreYellowCardTeamA" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="@dimen/padding8" | |
android:paddingStart="@dimen/padding8" | |
android:text="@string/scoreYellowCardA" | |
android:textSize="@dimen/Text_size_goal" /> | |
</LinearLayout> | |
</LinearLayout> | |
<View | |
android:id="@+id/divider" | |
android:layout_width="1dp" | |
android:layout_height="match_parent" | |
android:background="@android:color/black" /> | |
<!-- GroupView TeamB col --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:orientation="vertical" | |
android:paddingLeft="@dimen/padding64" | |
android:paddingStart="@dimen/padding64"> | |
<TextView | |
android:id="@+id/TeamB" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/teamB" | |
android:textSize="@dimen/Text_size_team" /> | |
<!-- goal row--> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scoreTeamB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scoreTeamB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addGoalTeamB" | |
android:text="@string/goalTeam" /> | |
</LinearLayout> | |
<!-- penalty row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scorePenaltyB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scorePenaltyB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addPenaltyTeamB" | |
android:text="@string/penaltyTeam" /> | |
</LinearLayout> | |
<!-- corner row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scoreCornerB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scoreCornerB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addCornerTeamB" | |
android:text="@string/cornerTeam" /> | |
</LinearLayout> | |
<!-- fault row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scoreFaultB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scoreFaultB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addFaultTeamB" | |
android:text="@string/faultTeam" /> | |
</LinearLayout> | |
<!-- redcard row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scoreRedCardTeamB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scoreRedCardB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addRedCardTeamB" | |
android:text="@string/redCardTeam" /> | |
</LinearLayout> | |
<!-- yellowcard row --> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/scoreYellowCardTeamB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingEnd="@dimen/padding8" | |
android:paddingRight="@dimen/padding8" | |
android:text="@string/scoreYellowCardB" | |
android:textSize="@dimen/Text_size_goal" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:onClick="addYellowCardTeamB" | |
android:text="@string/yellowCardTeam" /> | |
</LinearLayout> | |
</LinearLayout> | |
</LinearLayout> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" | |
android:onClick="resetAllScore" | |
android:layout_marginBottom="@dimen/margin_vertical_col" | |
android:text="@string/reset" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Default screen margins, per the Android Design guidelines. --> | |
<dimen name="activity_horizontal_margin">16dp</dimen> | |
<dimen name="activity_vertical_margin">128dp</dimen> | |
<dimen name="Text_size_team">32sp</dimen> | |
<dimen name="Text_size_goal">32sp</dimen> | |
<dimen name="Text_size_score">24sp</dimen> | |
<dimen name="horizontal_margin_scoreName">16dp</dimen> | |
<dimen name="margin_left_row">8dp</dimen> | |
<dimen name="margin_vertical_col">8dp</dimen> | |
<dimen name="padding72">72dp</dimen> | |
<dimen name="padding64">64dp</dimen> | |
<dimen name="padding8">8dp</dimen> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.scorekeeper; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.TextView; | |
import static android.icu.lang.UCharacter.GraphemeClusterBreak.V; | |
public class MainActivity extends AppCompatActivity { | |
int scoreCornerA = 0; | |
int scoreCornerB = 0; | |
int scoreFaultA = 0; | |
int scoreFaultB = 0; | |
int scorePenaltyA = 0; | |
int scorePenaltyB = 0; | |
int scoreRedCardA = 0; | |
int scoreRedCardB = 0; | |
int scoreTeamA = 0; | |
int scoreTeamB = 0; | |
int scoreYellowCardA = 0; | |
int scoreYellowCardB = 0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
/** | |
* Increase the goal for TeamA by 1 point | |
*/ | |
public void addGoalTeamA(View view) { | |
scoreTeamA = scoreTeamA + 1; | |
displayScoreTeamA(scoreTeamA); | |
} | |
/** | |
* Display the goal for teamA | |
*/ | |
public void displayScoreTeamA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreTeamA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the goal for TeamB by 1 point | |
*/ | |
public void addGoalTeamB(View view) { | |
scoreTeamB = scoreTeamB + 1; | |
displayScoreTeamB(scoreTeamB); | |
} | |
/** | |
* Display the goal for TeamB | |
*/ | |
public void displayScoreTeamB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreTeamB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the penalty for teamA by 1 point | |
*/ | |
public void addPenaltyTeamA(View view) { | |
scorePenaltyA = scorePenaltyA + 1; | |
displayScorePenaltyA(scorePenaltyA); | |
} | |
/** | |
* Display the penalty for TeamA | |
*/ | |
public void displayScorePenaltyA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scorePenaltyA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the penalty for teamB by 1 point | |
*/ | |
public void addPenaltyTeamB(View view) { | |
scorePenaltyB = scorePenaltyB + 1; | |
displayScorePenaltyB(scorePenaltyB); | |
} | |
/** | |
* Display the penalty for TeamB | |
*/ | |
public void displayScorePenaltyB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scorePenaltyB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the corner for TeamA by 1 point | |
*/ | |
public void addCornerTeamA(View view) { | |
scoreCornerA = scoreCornerA + 1; | |
displayScoreCornerA(scoreCornerA); | |
} | |
/** | |
* Display corner for TeamA | |
*/ | |
public void displayScoreCornerA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreCornerA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the corner for TeamB by 1 point | |
*/ | |
public void addCornerTeamB(View view) { | |
scoreCornerB = scoreCornerB + 1; | |
displayScoreCornerB(scoreCornerB); | |
} | |
/** | |
* Display corner for TeamB | |
*/ | |
public void displayScoreCornerB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreCornerB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the fault for TeamA by 1 point | |
*/ | |
public void addFaultTeamA(View view) { | |
scoreFaultA = scoreFaultA + 1; | |
displayScoreFaultA(scoreFaultA); | |
} | |
/** | |
* Display fault for TeamA | |
*/ | |
public void displayScoreFaultA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreFaultA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the fault for TeamB by 1 point | |
*/ | |
public void addFaultTeamB(View view) { | |
scoreFaultB = scoreFaultB + 1; | |
displayScoreFaultB(scoreFaultB); | |
} | |
/** | |
* Display fault for TeamB | |
*/ | |
public void displayScoreFaultB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreFaultB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the redCard for TeamA by 1 point | |
*/ | |
public void addRedCardTeamA(View view) { | |
scoreRedCardA = scoreRedCardA + 1; | |
displayScoreRedCardA(scoreRedCardA); | |
} | |
/** | |
* Display redCard for TeamA | |
*/ | |
public void displayScoreRedCardA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreRedCardTeamA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase the redCard for TeamB by 1 point | |
*/ | |
public void addRedCardTeamB(View view) { | |
scoreRedCardB = scoreRedCardB + 1; | |
displayScoreRedCardB(scoreRedCardB); | |
} | |
/** | |
* Display redCard for TeamB | |
*/ | |
public void displayScoreRedCardB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreRedCardTeamB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase yellowCard for TeamA by 1 point | |
*/ | |
public void addYellowCardTeamA(View view) { | |
scoreYellowCardA = scoreYellowCardA + 1; | |
displayScoreYellowCardA(scoreYellowCardA); | |
} | |
/** | |
* display yellowCard for TeamA | |
*/ | |
public void displayScoreYellowCardA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreYellowCardTeamA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Increase yellowCard for TeamB by 1 point | |
*/ | |
public void addYellowCardTeamB(View view) { | |
scoreYellowCardB = scoreYellowCardB + 1; | |
displayScoreYellowCardB(scoreYellowCardB); | |
} | |
/** | |
* display yellowCard for TeamB | |
*/ | |
public void displayScoreYellowCardB(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.scoreYellowCardTeamB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Reset all score | |
*/ | |
public void resetAllScore(View view) { | |
scoreTeamA = 0; | |
scoreTeamB = 0; | |
scorePenaltyA = 0; | |
scorePenaltyB = 0; | |
scoreCornerA = 0; | |
scoreCornerB = 0; | |
scoreFaultA = 0; | |
scoreFaultB = 0; | |
scoreRedCardA = 0; | |
scoreRedCardB = 0; | |
scoreYellowCardA = 0; | |
scoreYellowCardB = 0; | |
displayScoreTeamA(scoreTeamA); | |
displayScoreTeamB(scoreTeamB); | |
displayScorePenaltyA(scorePenaltyA); | |
displayScorePenaltyB(scorePenaltyB); | |
displayScoreCornerA(scoreCornerA); | |
displayScoreCornerB(scoreCornerB); | |
displayScoreFaultA(scoreFaultA); | |
displayScoreFaultB(scoreFaultB); | |
displayScoreRedCardA(scoreRedCardA); | |
displayScoreRedCardB(scoreRedCardB); | |
displayScoreYellowCardA(scoreYellowCardA); | |
displayScoreYellowCardB(scoreYellowCardB); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="app_name">ScoreKeeper</string> | |
<string name="teamA">TeamA</string> | |
<string name="teamB">TeamB</string> | |
<string name="scoreTeamA">0</string> | |
<string name="scoreTeamB">0</string> | |
<string name="penaltyTeam">penalty</string> | |
<string name="scorePenaltyA">0</string> | |
<string name="scorePenaltyB">0</string> | |
<string name="faultTeam">fault</string> | |
<string name="scoreFaultA">0</string> | |
<string name="scoreFaultB">0</string> | |
<string name="cornerTeam">corner</string> | |
<string name="scoreCornerA">0</string> | |
<string name="scoreCornerB">0</string> | |
<string name="goalTeam">goal!!!</string> | |
<string name="yellowCardTeam">yel-card</string> | |
<string name="redCardTeam">red-card</string> | |
<string name="scoreYellowCardA">0</string> | |
<string name="scoreYellowCardB">0</string> | |
<string name="scoreRedCardA">0</string> | |
<string name="scoreRedCardB">0</string> | |
<string name="desc">banner</string> | |
<string name="reset">reset</string> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar.ScoreKeeper"> | |
<!-- Customize your theme here. --> | |
<item name="android:textColorPrimary">@android:color/primary_text_dark</item> | |
</style> | |
<style name="Theme.AppCompat.Light.NoActionBar.ScoreKeeper" parent="Theme.AppCompat.Light.NoActionBar" > | |
<item name="colorAccent">@android:color/holo_blue_bright</item> | |
<!-- Background color of buttons in the app --> | |
<item name="colorButtonNormal">#424242</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment