admin 管理员组

文章数量: 887021


2023年12月25日发(作者:数据库设计视图创建查询)

//效果图:

//java代码部分:

package ;

import ty;

import ;

import ;

import kListener;

import ;

import xt;

public class MainActivity extends Activity {

// 定义九个数字

private Button one;

private Button two;

private Button three;

private Button four;

private Button five;

private Button six;

private Button seven;

private Button eight;

private Button nine;

private Button zero;

private Button dot;

private Button add;

private Button sub;

private Button mul;

private Button div;

private Button clear;

private Button equal;

private EditText led;

String num1 = "";

String num2 = "";

double num3 = 0;

String result = "";

String sign = "+";

int mark = 0;

boolean flag = true;

boolean dotmark = true;

@Override

protected void onCreate(Bundle savedInstanceState) {

te(savedInstanceState);

setContentView(ty_main);

zero = (Button) findViewById();

one = (Button) findViewById();

two = (Button) findViewById();

three = (Button) findViewById();

four = (Button) findViewById();

five = (Button) findViewById();

six = (Button) findViewById();

seven = (Button) findViewById();

eight = (Button) findViewById();

nine = (Button) findViewById();

add = (Button) findViewById();

sub = (Button) findViewById();

mul = (Button) findViewById();

div = (Button) findViewById();

clear = (Button) findViewById();

led = (EditText) findViewById();

equal = (Button) findViewById();

dot = (Button) findViewById();

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "0";

t(num1);

} else if (mark == 1) {

num2 = num2 + "0";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "0";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "1";

t(num1);

} else if (mark == 1) {

num2 = num2 + "1";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "1";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "2";

t(num1);

} else if (mark == 1) {

num2 = num2 + "2";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "2";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "3";

t(num1);

} else if (mark == 1) {

num2 = num2 + "3";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "3";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "4";

t(num1);

} else if (mark == 1) {

num2 = num2 + "4";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "4";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "5";

t(num1);

} else if (mark == 1) {

num2 = num2 + "5";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "5";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "6";

t(num1);

} else if (mark == 1) {

num2 = num2 + "6";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "6";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "7";

t(num1);

} else if (mark == 1) {

num2 = num2 + "7";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "7";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "8";

t(num1);

} else if (mark == 1) {

num2 = num2 + "8";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "8";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (mark == 0) {

num1 = num1 + "9";

t(num1);

} else if (mark == 1) {

num2 = num2 + "9";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + "9";

t(num1 + sign + num2);

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (flag) {

sign = "+";

mark++;

flag = false;

dotmark = true;

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (flag) {

sign = "-";

mark++;

flag = false;

dotmark = true;

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (flag) {

sign = "*";

mark++;

flag = false;

dotmark = true;

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (flag) {

sign = "÷";

mark++;

flag = false;

dotmark = true;

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

if (dotmark) {

if (mark == 0) {

num1 = num1 + ".";

t(num1);

} else if (mark == 1) {

num2 = num2 + ".";

t(num1 + sign + num2);

} else {

num1 = f(num3);

num2 = num2 + ".";

t(num1 + sign + num2);

}

dotmark = false;

}

}

});

lickListener(new OnClickListener() { // 等于时发生的运算

public void onClick(View v) {

flag = true;

dotmark = true;

if (("+")) {

double x = ouble(num1);

double y = ouble(num2);

num3 = x + y;

result = f(num3);

t(num1 + sign + num2 + "=" + result);

num2 = "";

} else if (("-")) {

double x = ouble(num1);

double y = ouble(num2);

num3 = x - y;

result = f(num3);

t(num1 + sign + num2 + "=" + result);

num2 = "";

} else if (("*")) {

double x = ouble(num1);

double y = ouble(num2);

num3 = x * y;

result = f(num3);

t(num1 + sign + num2 + "=" + result);

num2 = "";

} else if (("÷")) {

double x = ouble(num1);

double y = ouble(num2);

num3 = x / y;

result = f(num3);

t(num1 + sign + num2 + "=" + result);

num2 = "";

} else if (("^")) {

double x = ouble(num1);

double y = ouble(num2);

num3 = (x, y);

result = f(num3);

t(num1 + sign + num2 + "=" + result);

num2 = "";

}

}

});

lickListener(new OnClickListener() {

public void onClick(View v) {

num1 = "";

num2 = "";

num3 = 0;

mark = 0;

sign = "";

t("0");

flag = true;

dotmark = true;

}

});

}

}

Layout布局:

xmlns:android="/apk/res/android"

xmlns:tools="/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#000"

android:orientation="vertical"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity" >

android:id="@+id/led"

android:layout_width="288dp"

android:layout_height="79dp"

android:background="#000"

android:gravity="top|right"

android:text="0"

android:textColor="#FFF"

android:textSize="20pt"

android:textStyle="bold" />

android:layout_width="288dp"

android:layout_height="70dp"

android:orientation="horizontal" >


本文标签: 设计 视图 数据库 运算 部分