基本信息
源码名称:android 测身高标准体重 示例源码
源码大小:0.27M
文件格式:.apk
开发语言:Java
更新时间:2014-04-16
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
package com.mycompany.myapp5; import android.app.Activity;/* import 相关class */ import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.Toast; public class Ex10_UI extends Activity { protected int my_requestCode = 1550; private EditText edit_height; private RadioButton radiobutton_Man, radiobutton_Woman; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* 载入main.xml Layout */ setContentView(R.layout.main); /* 以findViewById()取得Button 对象,并添加onClickListener */ Button ok = (Button) findViewById(R.id.button_OK); edit_height = (EditText) findViewById(R.id.height_Edit); radiobutton_Man = (RadioButton) findViewById(R.id.Sex_Man); radiobutton_Woman = (RadioButton) findViewById(R.id.Sex_Woman); ok.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { try { /* 取得输入的身高 */ double height = Double.parseDouble(edit_height.getText() .toString()); /* 取得选择的性别 */ String sex = ""; if (radiobutton_Man.isChecked()) { sex = "M"; } else { sex = "F"; } /* new 一个Intent 对象,并指定class */ Intent intent = new Intent(); intent.setClass(Ex10_UI.this, BMIActivity.class); /* new 一个Bundle对象,并将要传递的数据传入 */ Bundle bundle = new Bundle(); bundle.putDouble("height", height); bundle.putString("sex", sex); /* 将Bundle 对象assign 给Intent */ intent.putExtras(bundle); /* 调用Activity EX03_10_1 */ startActivityForResult(intent,my_requestCode); } catch (Exception e) { // TODO: handle exception Toast.makeText(Ex10_UI.this, R.string.errorString, Toast.LENGTH_LONG).show(); } } }); } /* @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); switch (resultCode) { case RESULT_OK: /* 取得来自Activity2 的数据,并显示于画面上 Bundle bunde = data.getExtras(); String sex = bunde.getString("sex"); double height = bunde.getDouble("height"); edit_height.setText("" height); if (sex.equals("M")) { radiobutton_Man.setChecked(true); } else { radiobutton_Woman.setChecked(true); } break; default: break; } }*/ }