-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
47 lines (34 loc) · 819 Bytes
/
Card.java
File metadata and controls
47 lines (34 loc) · 819 Bytes
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
package com.jikexueyuan.game2048;
import android.content.Context;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;
public class Card extends FrameLayout {
public Card(Context context) {
super(context);
label = new TextView(getContext());
label.setTextSize(32);
label.setBackgroundColor(0x33ffffff);
label.setGravity(Gravity.CENTER);
LayoutParams lp = new LayoutParams(-1, -1);
lp.setMargins(10, 10, 0, 0);
addView(label, lp);
setNum(0);
}
private int num = 0;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
if (num<=0) {
label.setText("");
}else{
label.setText(num+"");
}
}
public boolean equals(Card o) {
return getNum()==o.getNum();
}
private TextView label;
}