Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AG-005-2] Create intent 'Back to Main' in 'Achievements' Activity #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:supportsRtl="true"
android:theme="@style/Theme.MemoCards">
<activity android:name=".Leaderboards"></activity>
<activity android:name=".Achievements" />
<activity android:name=".Achievements"
android:parentActivityName=".MainActivity"/>
<activity android:name=".Settings" />
<activity android:name=".Game" />
<activity android:name=".Levels" />
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/example/memocards/Achievements.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Achievements extends AppCompatActivity {

private Button backButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_achievements);

this.backButton = this.findViewById(R.id.back_button);

// When user click "Back" button.
this.backButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
// Back to main Activity.
Intent intent = new Intent (Achievements.this, MainActivity.class );
startActivity(intent);
}
});
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/memocards/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class MainActivity extends AppCompatActivity{

private Button play;
private Button achievments;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -24,6 +25,15 @@ public void onClick(View v) {
}
});

achievments = findViewById(R.id.achievements);
achievments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Achievements.class);
startActivity(intent);
}
});


}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_achievements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@
android:layout_height="match_parent"
tools:context=".Achievements">

<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="664dp"
android:text="@string/back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
android:text="@string/settings" />

<Button
android:id="@+id/achievments"
android:id="@+id/achievements"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<string name="difficult">Difficult</string>
<string name="Back">back</string>
<string name="Home">home</string>
<string name="back">BACK</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath 'com.android.tools.build:gradle:4.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jan 18 10:55:10 CET 2021
sdk.dir=C\:\\Users\\Des\\AppData\\Local\\Android\\Sdk
#Wed Jan 27 14:13:30 CET 2021
sdk.dir=C\:\\Users\\Sharus\\AppData\\Local\\Android\\Sdk