Android实现体重测量仪的源码

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
public class BundleObject extends Activity {
private Button mButton;
private EditText mEditText;
private RadioGroup mRadioGroup;
private double height;
private String Sex;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButton=(Button)findViewById(R.id.confirm);
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mEditText=(EditText)findViewById(R.id.heigt);
if(mEditText.getText().toString().length()==0)
{
/* AlertDialog builder = new AlertDialog.Builder(BundleObject.this).create();
builder.setTitle("提示");
builder.setMessage("請輸入您的身高!!");
builder.show();*/
new AlertDialog.Builder(BundleObject.this)
.setMessage("请輸入您的身高")
.setTitle("提示")
.setNeutralButton("确定",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
mEditText.setHighlightColor(Color.RED);
}
}).create()
.show();
return;
}
mRadioGroup=(RadioGroup)findViewById(R.id.sex);
height=Double.parseDouble(mEditText.getText().toString());
if(mRadioGroup.getCheckedRadioButtonId()==R.id.M)
{
Sex="M";
}
else
{
Sex="F";
}
Intent intent=new Intent();
intent.setClass(BundleObject.this, Next.class);
Bundle bun=new Bundle();
bun.putDouble("Height", height);
bun.putString("Sex", Sex);
intent.putExtras(bun);
startActivity(intent);
BundleObject.this.finish();
}
});
}
}

Android相关内容:

  • Android如何为APK文件进行签名
  • Android怎么为自定义组件注册属性
  • android怎么使用XML的方式为背景添加渐变的效果
  • android在ActivityGroup里面如何访问子Activity的View 并操作它去改变UI
  • Android实现动画旋转的源代码

你可能感兴趣的:(Android实现体重测量仪的源码)