Java代码
package com.example.work1;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
public class HeightCalculatorActivity extends Activity {
private Button calculatorButton;
private EditText weightEditText;
private EditText heightEditText;
private CheckBox manCheckBox;
private CheckBox womanCheckBox;
private TextView resultTextView;
private EditText nameEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.work);
calculatorButton = (Button) findViewById(R.id.caculator);
weightEditText = (EditText) findViewById(R.id.weight);
heightEditText = (EditText) findViewById(R.id.height);
manCheckBox = (CheckBox) findViewById(R.id.man);
womanCheckBox = (CheckBox) findViewById(R.id.woman);
resultTextView = (TextView) findViewById(R.id.result);
nameEditText=findViewById(R.id.name);
}
protected void onStart() {
super.onStart();
registerEvent();
}
private void registerEvent() {
calculatorButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (!weightEditText.getText().toString().trim().equals("")) {