WEB开发网
开发学院手机开发Android 开发 Android 体重测仪器开发 阅读

Android 体重测仪器开发

 2010-11-05 00:55:48 来源:WEB开发网   
核心提示:/*调用Activity EX03_11_1*/startActivityForResult(intent,0);}});}/* 覆盖 onActivityResult()*/@Overrideprotected void onActivityResult(int requestCode, int resultCode

/*调用Activity EX03_11_1*/

startActivityForResult(intent,0);

}

});

}

/* 覆盖 onActivityResult()*/

@Override

protected void onActivityResult(int requestCode, int resultCode,

Intent data)

{

switch (resultCode)

{

case RESULT_OK:

/* 取得来自Activity2的数据,并显示于画面上 */

Bundle bunde = data.getExtras();

String sex = bunde.getString("sex");

double height = bunde.getDouble("height");

et.setText(""+height);

if(sex.equals("M"))

{

rb1.setChecked(true);

}

else

{

rb2.setChecked(true);

}

break;

default:

break;

}

}

}

package irdc.ex03_11;

/* import相关class */

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.RadioButton;

public class EX03_11 extends Activity

{

private EditText et;

private RadioButton rb1;

private RadioButton rb2;

/** 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 b1 = (Button) findViewById(R.id.button1);

b1.setOnClickListener(new Button.OnClickListener()

{

public void onClick(View v)

{

/*取得输入的身高*/

上一页  1 2 3 4 5 6  下一页

Tags:Android 体重 测仪器

编辑录入:coldstar [复制链接] [打 印]
赞助商链接