본문 바로가기
Android/Android

Android 흑과백 게임

by 미티치 2016. 6. 13.

흑과 백 게임 룰

1) 0부터 8까지 9장의 숫자 타일 중 0,2,4,6,8은 흑색 타일, 1,3,5,7은 백색 타일로 구성되어있습니다.

2) 사용자는 0부터 8까지의 숫자타일 중 1개를 제시합니다.

3) 컴퓨터도 0부터 8까지의 숫자 타일 중 1개를 제시합니다

3) 더 높은 숫자타일을 제시한 플레이어가 승리 승점+1점을 획득합니다.

 

 

Android 흑과 백 게임

 

1. 게임 시작 화면

 

 

2. 다음과 같이 사용자의 이름을 적고 GAME START버튼을 클릭 합니다.

 

 

3. 다음과 같이 게임 룰이 소개되고, 컴퓨터와 사용자가 갖고있는 타일이 나열되어있는 모습을 볼 수 있습니다. 여기서 GAME START 버튼을 클릭

 

 

4. GAME START 버튼을 클릭하고, 사용자의 카드는 하단에 나와있는 0~8까지. 이 중에서 내려는 카드 숫자버튼을 클릭하면 Betago가 낸 카드와 숫자를 비교해서 승패를 알려준다.

- 이름옆에 점수 판에 이긴 사람의 점수에 +1점이 되고, 같은 숫자를 내서 무승부이면 둘 다 점수 변동이 없다.

 

 

 

5. 마지막 카드 8을 누르면 게임이 종료되고 승패와 함께 여태까지 냈던 카드의 숫자들을 보여준다.

 

 

 

 

 

Android 흑과 백 게임 소스

 

[ AndroidManifest.xml ]

: GameRunningActivity 등록

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mijinpark.blackandwhite">
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".GameRunningActivity"></activity>
    </application>
 
</manifest>
cs

 

 

[ MainActivity.java ]

 

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
package com.example.mijinpark.blackandwhite;
 
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
 
public class MainActivity extends Activity {
 
    Button btnGameStart;
    TextView textViewLoading;
    EditText userId;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        btnGameStart = (Button) findViewById(R.id.btnGameStart);
        textViewLoading = (TextView) findViewById(R.id.textViewLoading);
        userId = (EditText) findViewById(R.id.userId);
 
        btnGameStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                
                textViewLoading.setText("게임을 시작합니다");
                try{
                    Thread.sleep(1000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                Intent intent = new Intent(MainActivity.this,GameRunningActivity.class);
                intent.putExtra("userId", userId.getText().toString());
                startActivityForResult(intent,10);
            }
        });
 
    }
 
 
}
 
cs

 

 

[ GameRunningActivity.java ]

 

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package com.example.mijinpark.blackandwhite;
 
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
 
import java.util.Random;
 
/**
 * Created by MiJin Park on 2016-06-07.
 */
public class GameRunningActivity extends Activity {
 
    TextView textViewTop;
    TextView textViewcomCard;
    TextView textViewuserCard;
    TextView comId;
    TextView userId;
    TextView textViewcomScore;
    TextView textViewuserScore;
    TextView comCardAll;
    TextView userCardAll;
    Button btnGameStart;
    LinearLayout frameGameStart;
    LinearLayout frameCard;
    LinearLayout frameGameOver;
 
    // 변수
    int[] comCard;      // 컴퓨터가 넣을 카드
    int[] userCard;     // 유저가 넣는 가드
    int comScore = 0;   // 컴퓨터 점수
    int userScore = 0;  // user 점수
    int cnt=0;
    int numClickCount=0;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gamerunning);
 
        /**********************************************************************************/
        textViewTop = (TextView) findViewById(R.id.textViewTop);
        textViewcomCard = (TextView) findViewById(R.id.comCard);
        textViewuserCard = (TextView) findViewById(R.id.userCard);
        btnGameStart = (Button) findViewById(R.id.buttonGameStart);
        frameGameStart = (LinearLayout) findViewById(R.id.frameGameStart);
        frameCard = (LinearLayout) findViewById(R.id.frameCard);
        frameGameOver =(LinearLayout) findViewById(R.id.frameGameOver);
        comId = (TextView) findViewById(R.id.comId);
        userId = (TextView) findViewById(R.id.userId);
        textViewcomScore =(TextView) findViewById(R.id.comScore);
        textViewuserScore =(TextView) findViewById(R.id.userScore);
        comCardAll = (TextView) findViewById(R.id.comCardAll);
        userCardAll =(TextView) findViewById(R.id.userCardAll);
 
        comCard = new int[9];       //com이 랜덤으로 뽑은 숫자를 넣어놓을 배열
        userCard = new int[9];      //사용자가 랜덤으로 뽑은 숫자를 넣어놓을 배열
 
        /**********************************************************************************/
        /* 게임시작 버튼 누르면 실행되는 메소드 */
        btnGameStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //텍스트 뷰 바뀜
                textViewTop.setText("Please choose the number");
                //frameCard visible
                frameGameStart.setVisibility(View.INVISIBLE);
                frameCard.setVisibility(View.VISIBLE);
                //사용자 아이디 설정
                Intent intent = getIntent();
                userId.setText(intent.getExtras().getString("userId").toString()+"님");
            }
        });
        //액티비티 생성시 랜덤 숫자 뽑기
        getComCard();
    }
 
    /**********************************************************************************/
    //시작할 때 랜덤으로 숫자를 뽑음
    public void getComCard () {
        Random random = new Random();
 
        // 0부터 8까지 숫자를 무작위로 뽑아서 comCard 배열에 넣음
        MySet mySet = new MySet();
        while(true){
            mySet.add(random.nextInt(9));
            if (mySet.length()==10){
                break;
            }
        }
 
        comCard = mySet.getArr();
    }
 
    /**********************************************************************************/
    //user가 내는 카드의 버튼을 누르면 실행되는 메소드
    public void numClick(View v){
 
        numClickCount+=1;
        //userCard에 setText("버튼숫자");
        textViewuserCard.setText(((Button)v).getText()+"");
        //배열에 내가 선택한 숫자 넣기
        userCard[numClickCount-1= Integer.parseInt(((Button)v).getText().toString());
        //버튼 비활성화 및 이미 선택했던 버튼은 색깔을 회색으로 바꿈
        v.setActivated(false);
        ((Button)v).setBackgroundColor(Color.parseColor("#747474"));
 
 
        //베타고가 숫자를 뽑음
        //textViewTop.setText("Betago have chosen the number.");
 
        //베타고가 뽑은 숫자가 짝수인지 홀수인지 보여줌
        if(comCard[cnt]%2==0){
            textViewcomCard.setBackgroundColor(Color.parseColor("#000000"));
            textViewcomCard.setTextColor(Color.parseColor("#ffffff"));
        }else{
            textViewcomCard.setBackgroundColor(Color.parseColor("#ffffff"));
            textViewcomCard.setTextColor(Color.parseColor("#000000"));
        }
 
        // 베타고 승
        if(comCard[cnt] > Integer.parseInt(((Button)v).getText().toString())){
            Toast.makeText(getApplicationContext(),"Betago Win!",Toast.LENGTH_SHORT).show();
            comScore += 1;
            textViewTop.setText("Betago's Score +1");
            textViewcomScore.setText(" ["+comScore+"] ");
        }
        // 사용자 승
        else if(comCard[cnt] < Integer.parseInt(((Button)v).getText().toString())){
            Toast.makeText(getApplicationContext(),"User Win!",Toast.LENGTH_SHORT).show();
            userScore += 1;
            textViewTop.setText("User's Score +1");
            textViewuserScore.setText(" ["+userScore+"] ");
        }
        //무승부
        else {
            textViewTop.setText("Draw");
            Toast.makeText(getApplicationContext(),"Draw!",Toast.LENGTH_SHORT).show();
        }
 
        cnt +=1;
        //버튼 클릭한 횟수가 총 9번이면, 즉 모든 버튼을 다 클릭했으면 게임 종료
        if(numClickCount == 9){
            //게임 종료 메소드
            gameOver();
        }
    }
 
    /**********************************************************************************/
    public void gameOver(){
        frameGameStart.setVisibility(View.INVISIBLE);
        frameCard.setVisibility(View.INVISIBLE);
        frameGameOver.setVisibility(View.VISIBLE);
 
        comCardAll.setText("Betago : "+"["+comCard[0]+"] "+"["+comCard[1]+"] "+"["+comCard[2]+"] "+"["+comCard[3]+"] "+"["+comCard[4]+"] "+"["+comCard[5]+"] "+"["+comCard[6]+"] "+"["+comCard[7]+"] "+"["+comCard[8]+"] ");
        userCardAll.setText(userId.getText().toString()+" : "+"["+userCard[0]+"] "+"["+userCard[1]+"] "+"["+userCard[2]+"] "+"["+userCard[3]+"] "+"["+userCard[4]+"] "+"["+userCard[5]+"] "+"["+userCard[6]+"] "+"["+userCard[7]+"] "+"["+userCard[8]+"] ");
 
        //사용자 승
        if(userScore>comScore){
            Toast.makeText(getApplicationContext(),"Win!!",Toast.LENGTH_LONG).show();
        }
        //베타고 승
        else if(userScore<comScore){
            Toast.makeText(getApplicationContext(),"Lose!!",Toast.LENGTH_LONG).show();
        }
    }
 
}
 
cs

 

 

[ MySet.java ]

 

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
package com.example.mijinpark.blackandwhite;
 
import android.widget.Toast;
 
/**
 * Created by MiJin Park on 2016-06-13.
 */
public class MySet {
    int length = 0;
    int[] arr;
 
    public MySet() {
        arr = new int[9];
        for (int i=0; i<9; i++)
            arr[i]=-1;
    }
 
    public int[] getArr() {
        return arr;
    }
 
    public int length() {
        return length + 1;
    }
 
    public int add(int num) {
        int judge = 0;
        for (int i = 0; i < length; i++) {
            if (arr[i] == num) {
                judge++;
                break;
            }
        }
 
        if (judge == 0) {
            arr[length= num;
            length++;
        }
        return num;
    }
}
 
cs

 

 

[ activity_main.xml ]

 

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
<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.mijinpark.blackandwhite.MainActivity">
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="흑과백"
            android:textSize="@android:dimen/app_icon_size"
            android:textAlignment="center"
            android:gravity="center"/>
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">
 
        <TextView
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="사용자 아이디를 입력하세요"
            />
        <EditText
            android:id="@+id/userId"
            android:layout_gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/btnGameStart"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="Game Start"/>
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
 
        <TextView
            android:id="@+id/textViewLoading"
            android:layout_gravity="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
 
</LinearLayout>
 
cs

 

 

[ activity_gamerunning.xml ]

 

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
 
        <TextView
            android:id="@+id/textViewTop"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Do you want to start the game?" />
 
    </LinearLayout>
 
    <!--************************************************************************-->
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
 
        <!-- 컴퓨터가 갖고있는 숫자 카드 뒷면 보여주기-->
        <Button
            android:id="@+id/combtn0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/combtn1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/combtn2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/combtn3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/combtn4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/combtn5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/combtn6"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/combtn7"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/combtn8"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="\?"
            android:textColor="#ffffff" />
 
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal">
 
        <TextView
            android:id="@+id/comId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Vetago님" />
 
        <TextView
            android:id="@+id/comScore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="[ 0점 ]" />
    </LinearLayout>
 
    <!--************************************************************************-->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:textAlignment="center">
 
        <LinearLayout
            android:id="@+id/frameGameStart"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
 
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center|top"
                android:gravity="left"
                android:text=" 흑과백 \n1.0부터8까지 9장의 숫자 타일을 중 0,2,4,6,8은 흑색, 1,3,5,7은 백색 타일로 구성되어있습니다.
\n2. 사용자는 0~8까지의 숫자타일 중 1개를 제시합니다.
\n3. 더 높은 숫자타일을 제시한 플레이어가 승리 승점을 획득한다." />
 
            <Button
                android:id="@+id/buttonGameStart"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_gravity="bottom|center"
                android:text="Game Start" />
        </LinearLayout>
 
        <LinearLayout
            android:id="@+id/frameCard"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimary"
            android:orientation="vertical"
            android:visibility="invisible">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:gravity="center">
                <!-- 컴퓨터가 낸 카드 -->
                <TextView
                    android:id="@+id/comCard"
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:gravity="top"
                    android:text="card"
                    android:textAlignment="center"
                    android:textSize="25dp" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:gravity="center">
                <!-- 사용자가 낸 카드 -->
                <TextView
                    android:id="@+id/userCard"
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:text="card"
                    android:textAlignment="center"
                    android:textSize="25dp" />
            </LinearLayout>
 
        </LinearLayout>
 
        <LinearLayout
            android:id="@+id/frameGameOver"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:visibility="invisible">
 
            <TextView
                android:id="@+id/comCardAll"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center|top"
                android:text="betago의 모든 카드" />
 
            <TextView
                android:id="@+id/userCardAll"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center|bottom"
                android:text="user의 모든 카드" />
        </LinearLayout>
 
    </FrameLayout>
 
    <!--************************************************************************-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal">
 
        <TextView
            android:id="@+id/userId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="user ID" />
 
        <TextView
            android:id="@+id/userScore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="[ 0 ]" />
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="bottom">
 
        <Button
            android:id="@+id/btn0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="0"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/btn1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="1"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/btn2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="2"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/btn3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="3"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/btn4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="4"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/btn5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="5"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/btn6"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="6"
            android:textColor="#ffffff" />
 
        <Button
            android:id="@+id/btn7"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:onClick="numClick"
            android:text="7"
            android:textColor="#000000" />
 
        <Button
            android:id="@+id/btn8"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#000000"
            android:onClick="numClick"
            android:text="8"
            android:textColor="#ffffff" />
 
    </LinearLayout>
 
</LinearLayout>
cs

'Android > Android' 카테고리의 다른 글

Android_잡다한 문법  (0) 2016.07.31
Android(9)_Slide Menu  (1) 2016.07.26
Android(7)_Push  (0) 2016.06.01
Android(5)_Intent  (0) 2016.05.31
Android 계산기  (0) 2016.05.31