-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinner.java
72 lines (64 loc) · 2.39 KB
/
Winner.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
package com.example.set4multiplayer;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
public class Winner extends Activity {
int imgSources[] = {R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4};
ImageView card1;
ImageView card2;
ImageView card3;
ImageView card4;
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.winner);
Intent i = getIntent();
String player = i.getExtras().getString("playerNo");
String cardVal = i.getExtras().getString("card");
t = (TextView)findViewById(R.id.Text1);
t.setText("Player "+Integer.parseInt(player)+ "Won!!!");
card1 = (ImageView)findViewById(R.id.imageButton1);
card2 = (ImageView)findViewById(R.id.imageButton2);
card3 = (ImageView)findViewById(R.id.imageButton3);
card4 = (ImageView)findViewById(R.id.imageButton4);
card1.setImageResource(imgSources[Integer.parseInt(cardVal)-1]);
card2.setImageResource(imgSources[Integer.parseInt(cardVal)-1]);
card3.setImageResource(imgSources[Integer.parseInt(cardVal)-1]);
card4.setImageResource(imgSources[Integer.parseInt(cardVal)-1]);
//setContentView(R.layout.winner);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}