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

TV stations dig their own graves as Netflix causes ratings to plummet

Netflix, a copyrighted video website, has become ...

Brand marketing planning basics

The 4P theory of marketing tells us product (prod...

Glass-hearted? App Store removes PP Assistant and 360 Mobile Assistant

When you work in someone else's place, you ha...

How far is generalized AI from true “artificial intelligence”?

Once upon a time, AI (artificial intelligence) be...

What is the best way to generate organic traffic on Tik Tok?

Nowadays, everyone on Douyin will try to get traf...

How to play with Tik Tok’s recommendation rules?

How to create a hit on Douyin? What are the six m...

These 5 changes in iOS14 interaction are worth studying carefully

I have always liked the interactive design of the...

How to conduct data analysis for operational promotion?

Talking about data analysis theory alone is too d...

Five software development trends for 2020

Over the past few years, a lot of software develo...

Advice from 5 senior APP promoters to practitioners

In the process of acquiring APP users, the compet...