-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardActivity.java
More file actions
65 lines (53 loc) · 1.7 KB
/
CardActivity.java
File metadata and controls
65 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.example.puzzlewise;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class CardActivity extends AppCompatActivity {
Button card, reset, home;
int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_card);
Bundle extras = getIntent().getExtras();
final String[] cardList = extras.getStringArray("cardList");
card = findViewById(R.id.card);
card.setText("Click Me!");
card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
card.setText(cardList[count]);
count++;
if (count == cardList.length) {
count = 0;
}
}
});
home = findViewById(R.id.home);
home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openMainActivity();
}
});
reset = findViewById(R.id.reset);
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWordsActivity();
}
});
}
public void openMainActivity()
{
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
public void openWordsActivity()
{
Intent intent = new Intent(this, wordsActivity.class);
startActivity(intent);
}
}