阅读更多

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实现动画旋转的源代码

更多相关文章

  1. Android(安卓)打包失败,提示 Android(安卓)resource linking fail
  2. Android(安卓)UI控件详解-AutoComplete-TextView(自动提示)
  3. android通知栏提示
  4. Android检测网络连接并提示
  5. Android搜索框自动提示文本框——(单一提示)
  6. android实现自动提示功能
  7. Android:res之shape制作圆角、虚线、渐变
  8. Android(安卓)之shape
  9. Android正在启动的提示框

随机推荐

  1. android 获取屏幕宽高 & 控件宽高
  2. 刷机
  3. 自定义线程池ThreadPoolExecutor
  4. Android(安卓)简单调用摄像头
  5. Android(安卓)ListView 中的CheckBox点击
  6. Animator cancel end
  7. Android使用AnysnTask强求数据
  8. Error inflating class androidx.constra
  9. Android之setOnClickListener()
  10. [Android基础知识][1] SpannableString属