项目托管平台地址:https://gitee.com/lvhong/ShiTouJianDaoBu
开发模块功能:点击按钮生成相对的石头剪刀布
开发时间:1天
点击按钮生成相对的石头剪刀布
实现过程是
package com.example.admin.sjb;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Created by admin on 2017/11/7.
*/
public class PeopleActivity extends AppCompatActivity {
private TextView tv1;
private TextView tv2;
private ImageView iv;
private int random = 0;
private int play = 1,play1,play2;//用户出拳
private Button bt1;
private Button bt2;
private Button bt3;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_people);
tv1=(TextView)findViewById(R.id.textView);
tv2=(TextView)findViewById(R.id.button4);
iv=(ImageView)findViewById(R.id.imageView);
bt2=(Button)findViewById(R.id.button);
bt1=(Button)findViewById(R.id.button2);
bt3=(Button)findViewById(R.id.button3);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iv.setImageResource(R.drawable.shi);
play = 1;
}
});
bt2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iv.setImageResource(R.drawable.jian);
play = 2;
}
});
bt3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iv.setImageResource(R.drawable.bu);
play = 3;
}
});