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

The failure of community fission, my three lessons

Looking back at 2019, a new concept has become po...

Debug your code like a doctor

Designing and maintaining good software is a neve...

Startup products: How to scale up offline?

Recently, I have been learning how startups can s...

Review the promotion and operation methods of the 618 event!

In this article, the author will take the 618 Mid...

Apple sells ads on the App Store, what does this mean?

How are Apple App Store’s default search ads made...

The 5 most profitable ways to monetize Douyin live streaming

The sweet-looking and high-quality dance video of...

Why do I feel so tired even though I just sit all day at work?

Everyone has probably experienced this moment at ...

There are 5 super carcinogens hidden around us. Check if you eat them often!

Have you ever paid attention to the carcinogens a...