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

Data operation: How to use data analysis to improve user retention?

Acquiring users is only the first step, but retai...

What pitfalls do programmers with a monthly salary of 30,000 avoid?

The salary of programmers varies. Some may earn 3...

The underlying logic and detailed design of the sharing of gift fission gameplay

Since the transformation to operation, we have be...

The bird on the national emblem smells like cow dung

The national emblem of the Cooperative Republic o...

Why is 2015 the first year of microservice architecture?

[[127190]] Editor's note: Microservice archit...

The 4 core elements of B-side community operations!

As a community operator, he started to engage in ...

How to achieve the best results with Google multimedia ads?

Millions of dollars are invested in Google Displa...

Michigan government uses VW compensation to promote ZEV development

According to foreign media reports, the Michigan ...

Case Review | QQ Browser News New User Retention Growth Methodology

By reviewing a growth case I did last year - the ...

Xpeng: 4,224 units delivered in November 2020, a record high

On December 1, 2020, Xpeng Motors announced that ...