GuessGame——Guessing Game

GuessGame——Guessing Game

Source code introduction

GuessGame——Guess, paper-scissors game, my first software.
Source code running screenshot

Source code snippet

  1. package com.guessgame;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.view.Menu;
  6. import android.view.MenuItem;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12. public   class GuessGameActivity extends Activity {
  13. private TextView introduction;
  14. private Button Zhangfei;
  15. private Button Liubei;
  16. private Button Guanyu;
  17. private EditText peopleSelext;
  18. private Button begin;
  19. private Button gengxin;
  20. @Override  
  21. public   void onCreate(Bundle savedInstanceState) {
  22. super .onCreate(savedInstanceState);
  23. setContentView(R.layout.main);
  24. Zhangfei=(Button)findViewById(R.id.Zhangfei);
  25. Liubei=(Button)findViewById(R.id.Liubei);
  26. Guanyu=(Button)findViewById(R.id.Guanyu);
  27. peopleSelext=(EditText)findViewById(R.id.peopleSelext);
  28. begin=(Button)findViewById(R.id.begin);
  29. gengxin=(Button)findViewById(R.id.gengxin);
  30. // Binding  
  31. Zhangfei.setOnClickListener( new ZhangfeiListener());
  32. Liubei.setOnClickListener( new LiubeiListener());
  33. Guanyu.setOnClickListener( new GuanyuListener());
  34. begin.setOnClickListener( new beginGame());
  35. gengxin.setOnClickListener( new GengxinListener());
  36.           
  37. }
  38. /**
  39. * Button Listener
  40. */  
  41. //renew  
  42. class GengxinListener implements OnClickListener{
  43. @Override  
  44. public   void onClick(View v) {
  45. // TODO Auto-generated method stub  
  46. Intent intent= new Intent();
  47. intent.setClass(GuessGameActivity. this , Update. class );
  48. startActivity(intent);
  49. }
  50. }
  51. class ZhangfeiListener implements OnClickListener{
  52.   
  53. @Override  
  54. public   void onClick(View v) {
  55. String select = "Zhang Fei" ;
  56. peopleSelext.setText(select);
  57.               
  58. }
  59. }
  60. class LiubeiListener implements OnClickListener{
  61.   
  62. @Override  
  63. public   void onClick(View v) {
  64. String select = "Liu Bei" ;
  65. peopleSelext.setText(select);
  66. }
  67. }
  68. class GuanyuListener implements OnClickListener{
  69.   
  70. @Override  
  71. public   void onClick(View v) {
  72. String select = "Guan Yu" ;
  73. peopleSelext.setText(select);
  74. }
  75. }
  76. class beginGame implements OnClickListener{
  77. @Override  
  78. public   void onClick(View v) {
  79. Intent intent = new Intent();
  80. String PeoString=peopleSelext.getText().toString();
  81. intent.putExtra( "peopleSelext" , PeoString);
  82. intent.setClass(GuessGameActivity. this , GameUI. class );
  83. startActivity(intent);
  84.               
  85. }
  86. }
  87.       
  88. //Add a menu to copy a method  
  89. @Override  
  90. public   boolean onCreateOptionsMenu(Menu menu) {
  91. menu.add( 0 , 1 , 1 , "Exit" );
  92. return   super .onCreateOptionsMenu(menu);
  93. }
  94. //Add an operation to the menu item and also copy a method  
  95. @Override  
  96. public   boolean onOptionsItemSelected(MenuItem item) {
  97. if (item.getItemId()== 1 ){
  98. finish();
  99. }
  100.           
  101. return   super .onOptionsItemSelected(item);
  102. }
  103.        
  104. }

Source code link: http://download..com/data/1975257

<<:  Easy custom camera

>>:  High imitation Xiaomi Mall splash animation

Recommend

How to create Alipay mini program and join Taobao mini program?

Q: How to create Alipay mini program and join Tao...

Kuaishou Account Practical Operation Guide

1. How to formulate an operation plan for a new a...

You can have vanilla ice cream thanks to this boy

The online game World of Warcraft carries the you...

Show you how to master advanced CP operation routines!

In 2015, I have been troubled by APP promotion an...

Volvo recalls 74,000 vehicles in the US, including the S90

According to foreign media reports, Volvo will re...

APIStore——Technology innovation thinking from Baidu

Mobile Internet, along with the concept of "...

How to formulate an APP marketing and promotion plan? Share 2 points!

Before writing a promotion plan, you must make a ...