国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

一個算數(shù)小游戲的代碼

2020-08-24 18:41 作者:MogMouG  | 我要投稿

JAVA代碼

package com.mycompany.myapp2;


import android.app.*;

import android.os.*;

import android.view.*;

import android.view.View.*;

import android.widget.*;

public class MainActivity extends Activity?

{

? ??

?int max=10,min=1;

?int jiashu1 = (int) (Math.random() * (max - min) + min);?

?int jiashu2 = (int) (Math.random() * (max - min) + min);

?private TextView text = null;

?private Button btn = null;

?private EditText edit = null;

?private TextView exp = null;

? ? @Override

? ? protected void onCreate(Bundle savedInstanceState)

? ? {

? super.onCreate(savedInstanceState);

? ? ? ? setContentView(R.layout.main);

? this.exp = (TextView)super.findViewById(R.id.exp);

? this.text = (TextView)super.findViewById(R.id.text);

? this.btn = (Button)super.findViewById(R.id.btn);

? this.edit = (EditText)super.findViewById(R.id.edit);

? text.setText(jiashu1+"+"+jiashu2+"=?");

? btn.setOnClickListener(new btnClick());

? ? }

?private class btnClick implements OnClickListener

?{

? public void onClick(View v)

? {

? ?int sum2 = (jiashu1 + jiashu2);

? ?int sum1 = Integer.valueOf(edit.getText().toString());

? ?//Toast.makeText(MainActivity.this,,Toast.LENGTH_SHORT).show();

? ?if (sum2==sum1)

? ?{

? ? exp.setText("??");

? ?}

? ?else

? ?{

? ? exp.setText("??");

? ?}

? ?int max=10,min=1;

? ?jiashu1 = (int) (Math.random() * (max - min) + min);?

? ?jiashu2 = (int) (Math.random() * (max - min) + min);

? ?text.setText(jiashu1+"+"+jiashu2+"=?");

? }

?}

}

XML文件

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

?xmlns:android="http://schemas.android.com/apk/res/android"

?android:layout_width="match_parent"

?android:layout_height="match_parent"

?android:orientation="vertical"

?android:id="@+id/mainLinearLayout1"

?android:alpha="1">


?<LinearLayout

? android:layout_height="wrap_content"

? android:layout_width="wrap_content"

? android:orientation="horizontal">


? <TextView

? ?android:layout_height="wrap_content"

? ?android:layout_width="wrap_content"

? ?android:text="1+1=?"

? ?android:id="@+id/text"

? ?android:textSize="35sp"/>


? <TextView

? ?android:layout_height="wrap_content"

? ?android:layout_width="wrap_content"

? ?android:text=""

? ?android:textSize="35sp"

? ?android:id="@+id/exp"/>


?</LinearLayout>


?<EditText

? android:layout_height="wrap_content"

? android:layout_width="wrap_content"

? android:ems="9"

? android:id="@+id/edit"

? android:hint="輸入數(shù)字"

? android:inputType="number"

? style="@style/AppTheme"/>


?<Button

? android:layout_height="wrap_content"

? android:layout_width="wrap_content"

? android:text="提交"

? android:id="@+id/btn"/>


</LinearLayout>


代碼都是自己寫的

大佬勿噴QAQ

一個算數(shù)小游戲的代碼的評論 (共 條)

分享到微博請遵守國家法律
克什克腾旗| 监利县| 上蔡县| 甘南县| 武穴市| 万源市| 临沧市| 剑川县| 阜康市| 喀喇沁旗| 满城县| 东丰县| 呼和浩特市| 朝阳市| 吉林市| 静乐县| 宁河县| 金塔县| 通海县| 蒙自县| 阳春市| 来安县| 黑龙江省| 沁水县| 波密县| 九龙县| 泌阳县| 彭水| 改则县| 林甸县| 达尔| 邵阳县| 安平县| 柳江县| 阿尔山市| 竹北市| 临沂市| 淅川县| 德清县| 邯郸市| 景宁|