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 future of mobile app development from the history of middleware

In the field of mobile development, we found a ve...

What Master brings to the world: Is it "out of control" or evolution?

[51CTO.com original article] Master shocked the G...

How should SEM bidders deal with the setbacks they may encounter in their work?

As an SEM person, you will encounter various prob...

SKYWORTH 55G9200 Geek TV Review: Sound, Picture and Game

1. Evaluation Introduction Skyworth recently laun...

Insights | Let go when it’s time to let go and learn to look forward

Famous Artists Gallery | Xie Zhiliu, a native of ...

3 tips for refined operation strategies!

As the cost of acquiring traffic gradually increa...

How to build an operation system?

When I wrote this title, I actually felt a little...

Uninstalling Chinese apps with one click: a small farce or a real crisis?

Recently, an application called Remove China Apps...